As luck would have it, I was in Beijing when word came of China's apparent hacking of the New York Times. The newspaper says it became the target of sustained cyber-attack immediately after it had revealed the vast fortune – estimated as "at least $2.7bn" – amassed by the family of China's outgoing premier, Wen Jiabao. Among the dead giveaways: hostile activity on the NYT's system dropped off during Chinese public holidays. It seems even state-sponsored hackers need a day off.

If CCTV, China's state broadcaster – now with its own 24-hour, English-language news channel – mentioned the story at all, then I missed it. But it raises an intriguing question: was this the act of a regime that is strong or weak? It takes nerve to attack a prestige institution of the global superpower. But it also looks nervy to be so clearly rattled by one disobliging media report. So which is it? After a week immersed in conversation with Chinese scholars, foreign diplomats and NGO observers, it's hard to disagree with the analyst who told me the answer is both: China's rulers are simultaneously "hugely powerful and hugely insecure".

Put the question another way. Two years ago, when the Arab spring first blossomed, there began a global guessing game as to who would be next. By rights, China should have been an obvious candidate. It's ruled by an authoritarian government, the trappings of totalitarianism still in place. (For a first-time visitor, it can be a shock to see the retro slogans – "Long Live the Spirit of the 18th Congress!" – projected on giant, high-definition TV screens, often alongside ads for western brands. I spotted a demand for "Patriotism, Innovation, Inclusiveness, Virtue" directly opposite a poster for L'Oreal Men Expert Hydrating Gel. That's modern Beijing: a cross between 1984 and a Westfield centre.) Add in public frustration with both widening inequality and the brazen corruption typified by the Wen case, and the ingredients for a Chinese spring should be in place.

And yet the notion is barely discussed, the prospect of a serious challenge to the regime regarded as somewhere between remote and nonexistent. The first explanation is the most obvious: the Chinese people are getting richer. One estimate says 300 million regard themselves as direct beneficiaries of the Chinese economic success story with a stake in maintaining the status quo. The novelist and law professor He Jiahong sees the difference between his students now and those he taught before 1989: today's generation, born after those crushed protests, has no interest in politics, only in getting on and making money. "They want a peaceful life," he told me. They suspect political action "would only bring chaos, like in Egypt".

Others suggest that, despite the absence of democracy, many Chinese people hardly believe themselves oppressed. So long as they don't criticise the ruling elite directly, they have fairly broad freedom of speech, able to vent on Chinese social networks such as Weibo without fearing a midnight knock on the door – a useful safety valve for the regime, ensuring dissent does not become so pent-up it eventually explodes.

It helps the authorities that public anger can be easily directed at an alternative target, namely Japan. Nationalist fury at China's enduring enemy is real and rising, fuelled by the dispute over the islands in the East China Sea. A sales assistant in the electronics department at a Beijing Walmart told me that since the row escalated last year he had sold only Chinese-made TV sets: no one wanted to buy the Sharp models made in Japan.

We in the west have played a role too. Pre-1989, Chinese pro-democracy campaigners would look westward and see not only a different political model but also greater economic success. They assumed that only the former could deliver the latter. That assumption now lies in pieces, thanks to the contrast between a roaring China and a stagnating west. The financial crash of 2008 broke the appeal of the western model, says Professor Shi Yinhong of Renmin University. "China is emancipated from that feeling of inferiority," he says.

All of which should leave the regime feeling secure in its own position. Yet it hardly acts that way. "They're acutely aware of the risk," reports one diplomat, describing how closely Beijing watched the Arab spring, seeking to learn from the ousted despots' mistakes. One immediate response was to prevent the possibility of large crowds, flooding popular areas with security personnel to disperse potential groups, even ordering street-sweeping vehicles to drive closer to the pavement in order to keep people moving. There may be some freedom of speech in today's China, but there's next to no freedom of association.

This anxiety of the regime's can go to absurd lengths. During last November's party congress they imposed a no-fly zone in the area, applied to balloons and model aeroplanes. That came after the mandatory removal of window handles from all Beijing taxis, lest anyone try to distribute subversive leaflets from a moving cab. Most revealing, China spends more on internal than external security. "That tells you what the government sees as its biggest threat – and it's not Japan or the US," says Stephanie Kleine-Ahlbrandt of the International Crisis Group.

Evidence of that nervousness comes in the way the regime caves so rapidly when confronted with China's equivalent of a Twitterstorm: call it a Weibo wave. Yang Dacai, a provincial official, paid the price last year when he was photographed grinning incongruously at the scene of a road crash that had left 36 dead. Weibo users turned on him, soon finding more pictures, this time showing him wearing a range of ultra-expensive wristwatches – all beyond the salary of a humble civil servant. Feeling the heat, the party investigated Yang for corruption and he was gone.

With Weibo users now in the high hundreds of millions, the regime regards this new political space with trepidation. The next wave could come over pollution. Some say the smog that clouded Beijing this week – leaving one diplomat's toddler "coughing like a 30-a-day smoker" – is testing the regime's legitimacy: what good is a government that can't ensure air clean enough to breathe? Once in denial over what they called "sea mist", China's rulers now discuss the smog as if they know they have to act – and fear the consequences if they fail.

Which is not to say a challenge is coming soon: I was told the Communist party has perhaps two or three decades in which to reform. The regime that rules China is mighty indeed. But the dragon seems to be trembling within.