The Channel logo


By | Scott Granneman 31st August 2005 07:19

On blocking Chinese IP addresses

The Great Firewall of China

Comment In the 1980s, I was unbeatable in Trivial Pursuit, and to this day, I still possess a love of trivia. Here's some neat facts about the Great Wall of China. Did you know...

  • The Great Wall sprawls more than 1500 miles in length.
  • You can see the Great Wall from low orbit, but not from the Moon (urban legend!).
  • With the materials used to build the Great Wall, you could build 120 Egyptian pyramids, or a six inch tall wall completely around the equator.
  • At its peak, one of every 3 Chinese men was busy building the Great Wall.
  • You know what Richard Nixon said when he was in China and was taken to the Great Wall? "I think that you would have to conclude that this is a great wall." It's true!

Recently I was thinking about China again when I heard two stories from friends that sounded eerily similar. In both cases, web servers were hacked due to a vulnerability in home-grown PHP apps, and after the inevitable (and always painful) server rebuilds, a new attention to security in totum was now observed. Unnecessary services were disabled, all scripts and third-party apps were carefully audited, and user privileges were tightened with a lug wrench. As part of the new attention to security, the admins began to pay close attention to the web server's access and error logs, and what they saw astonished them.

Their web servers were pounded constantly by requests for proxy services - and they weren't running proxies. Their web servers were asked, every few minutes, to run CGI scripts - and there weren't any CGI scripts on the machines. Requests for directory indexes came in fast and furious, and yet directory indexing was shut off. Someone was asking, over and over again, for files that didn't exist - files with really weird, suspicious names.

(I'm sure many of you are going to leave comments below saying "What idiots! How painfully obvious! Only a fool would be surprised by this stuff!" You may very well be correct in all three statements, but that still doesn't mean that many, many people do not know this stuff, and need to be educated about it.)

Even more interesting, the vast majority of these highly shady requests were coming from machines in China. The IP addresses ranged all over the map, but every time WHOIS was run on them, back came a block in China. Eventually, it seemed like every province in China was involved, as this fragmentary list shows:

  • Oriental Cable Network Co., Shanghai
  • China Guangdong Province Network
  • China Fujian Province Network
  • China Hubei Province Network
  • China Beijing Province Network
  • China Hangzhou Node Network
  • Shanghai sichuanshengpenganxianjianyezonggongsi Co., Ltd
  • China Anhui Province Network
  • China United Telecommunications Corporation, Xicheng District, Beijing, China
  • China Jiangmen Broadband Network

And on and on.

Both of my friends thought about their situations, and both came to the same conclusion: block the entire IP ranges! Use WHOIS to look up the IP address' range, then block 'em with the server's firewall. This quickly grew into a...

...mammoth, seemingly neverending task, but it immediately began to pay off. Fishy web server requests tapered off greatly, and while there are still a few every day, it's now become a manageable problem. If things keep up at the same pace, sometime in the next few months they're going to have blocked every IP in China. As Korean IPs pop up in the error log, those get blocked as well. And what about Taiwan? Russia? India? And more?

First, let's look at why China is such a problem. Well, to my mind, there are several potential causes for the flood of Chinese hackerish web requests.

New users. The middle class in China is growing, and since many, many computers are made in China and are therefore inexpensive, it's not surprising that more and more Chinese are buying PCs. Unfortunately, Chinese citizens are about as well-trained and about as security conscious as typical citizens in Western nations ... which means, not at all. One of my friends would always scan the IP addresses of the Chinese machines targeting him, and he reported that those machines invariably were riddled with hacker tools and open ports. Were the owners of these machines even aware that their computers were being used to attack other machines? Who knows? And what's the Chinese word for "owned"?

Chinese hackers. I have no doubt that there are gangs of Chinese hackers - whether employed by the government, organized crime, or freelance - that are working as hard as they can to take over computers around the world for all sorts of nefarious purposes. They're just like hacker gangs anywhere else in the world. Spam networks, phishing, DDOS attacks: it's all being done. There was a recent TIME magazine article about Chinese hackers that I found hysterical in tone and factuality, but the overall message of the piece rings true to me.

When they told me what they had done - independently, mind you, of each other - I asked them the same question: did you tell your web hosting clients? In both cases, they said they had not. In fact, one told me, "I'm hosting the web site of the local professional society, for instance, and there is absolutely no reason for anyone in China to access that site. I'm also hosting a site for nurses. Why would someone in China need that? I can't think of any clients who have content that a person in China would need to see. OK, I take that back. I have two churches on there, and maybe, maybe, a missionary or someone like that in China would want to access their sites. In that case, I figure that the church will get contacted, and then I'll get contacted, and at that time I'll allow access for that specific IP. But that's it. Anyone else in China - screw 'em."

I don't know what to think about that attitude. On the one hand, I can understand his frustration, and his logic makes sense... to a point. If none of his clients have web sites that someone in China has a good reason to access, then maybe it's OK to block them. On the other hand, how can he be so sure? And should it really be up to clients to have to figure out that over a billion Chinese can't access their sites? Should he tell his clients? Perhaps what his clients don't know will help keep them from getting confused.

Then there's also the legality of taking action against a hacker who has compromised a machine, after all the heavy forensics are done. It's hard enough to convince law enforcement to followup on a cyber crime; it's harder still when the hacker lives in another country. Blocking Chinese IP address ranges is one thing, but going further and blocking every country except where your organization (or client's organization) does business becomes a slippery slope very fast.

Here's a good question. What needs to come first: the needs of the web servers my friends run, or the needs of a guy sitting in Shanghai that wants to view the content of that web site? I'm not sure if the Chinese government even realizes the extent of the problems coming out of its IP space, or if it even cares. But if things don't improve sometime soon, Chinese Net users may find that they have more than just the government's odious Great Firewall to deal with; instead, they may be faced with millions of firewall blocks all over the world.

So tell me, and I'll pass your thoughts along to my friends: what should they do?

Copyright © 2005, SecurityFocus

Scott Granneman is a senior consultant for Bryan Consulting Inc. in St. Louis. He specializes in Internet Services and developing Web applications for corporate, educational, and institutional clients.

alert Send corrections


Frank Jennings

What do you do? Use manual typwriters or live in a Scottish croft? Our man advises
A rusty petrol pump at an abandoned gas station. Pic by Silvia B. Jakiello via shutterstock

Trevor Pott

Among other things, Active Directory needs an overhaul
Baby looks taken aback/shocked/affronted. Photo by Shutterstock

Kat Hall

Plans for 2 million FTTP connections in next four years 'not enough'
Microsoft CEO Satya Nadella


League of gentlemen poster - Tubbs and Edward at the local shop. Copyright BBC
One reselling man tells his tale of woe