- Home
- About
- Writing

Previous post Next post Back to top Share post

# Static Site what?!

TheBestJohn
2018-04-27

Recently I’ve become disillusioned with most CMS options. They’re a pain to keep updated, plugins are constantly being abandoned, and they’re so prevalent in sites that they make a very attractive target for exploitation. In fact the first time I lost control of my server it was because of a bug in a themes use of timthumb.php. Basically, the attacker sent it an “image” file from a hosting website that had a php eval script hidden in it’s data. When accessed normally it showed an image but if they accessed the cached file that timthumb made, then the server treated it as a php file. From there they were able to install a remote shell, and own my server.

### Static site generators

While the timthumb exploit was a pain in the ass, it was very interesting to me and made me interested in trying to secure my systems. To that end I started reading into static site generators. Static site generators take your posts, usually formatted in some sort of markup, puts them through a templating engine that outputs `.html` files, that you can then serve via the usual methods.

#### But, why?

The idea is that most sites don’t actually need to use dynamic code. Their content is, for the most, part static. Users aren’t interacting with the content (other than the comments sections and forms but we’ll talk about that later). They are, instead, just reading it. The only person who seems to be interacting with it is the person that owns the site. Even then, the owner isn’t actively interacting. They are writing a post, or updating a page. After that, everything stays the same.

### Enter, Hexo

Hexo is a neat little package.

Originally I thought I would install it, set up an apache virtual reverse proxy via an `.htaccess` file and let node serve static files. Some people do this. It’s a valid way to serve a site. The problem that I have with this, is that it’s just another vulnerable layer of code that I don’t have the inclination to audit. It could potentially have glaring security holes and I wouldn’t know. Again, I want to clarify that I don’t know much of anything about security. I’m not a cryptographer, nor an expert on cyber security. However, I can easily read the html that comes out the other end of the site generator and verify that there are no well-known issues with the javascript or html.

So what to do? Well, the output is a fully static html/css/js site. No need for node, no need for a reverse proxy. This will just work when popped into a public directory of a webserver.