Skip to content

Instantly share code, notes, and snippets.

@birkin
Last active August 10, 2023 19:08
Show Gist options
  • Save birkin/23c999684d90a52424419af33bf6fc8a to your computer and use it in GitHub Desktop.
Save birkin/23c999684d90a52424419af33bf6fc8a to your computer and use it in GitHub Desktop.
info

Static Site Security

Main points...

Non-static websites have a web-server which often receives user-input and then queries other server-tools: databases, search-indexes, queues. The act of user-input triggering reads and writes to server-tools creates vectors for serious vulnerabilities.

Static-sites still (usually) have a web-server -- but because all the web-server does is directly serve out simple files -- whole categories of serious vulnerabilities are eliminated.

But security-vulnerabilities can still exit in static-sites.

From the research-scan I've done, there are two main categories to be aware of:

  • the context in which the static-site is served
  • javascript vulnerabilites

Context tips...

  • Have the web-server configured to only serve out content via https vs http improves the ability for users to access site-data confidentially.
  • Have the web-server configured to send certain http-headers can mitigate risk of some javascript vulnerabilities. Examples:
    • X-Frame-Options: SAMEORIGIN (minimizes iframe-based cross-site-scripting attacks)
    • X-XSS-Protection: 1; mode=block (minimizes iframe-based cross-site-scripting attacks)
    • X-Content-Type-Options: nosniff (disables browser guessing the file-format)
    • Content-Type: text/html; charset=utf-8 (indirectly improves security by ensuring proper interpretation of content, minimizes encoding-obfuscation)

Javascript tips...

Most javascript vulnerabilities lead to allowing Cross-Site Scripting (XSS) attacks. This is a situation in which an attacker figures out a way to inject malicious javascript into your website, and have your browser run it, for nefarious purposes. Example, the malicious javascript could, upon you attempting to load a supposedly public-page, put up a form requesting you to log in with your google credentials, to steal them.

  • Load javascript libraries from your own web-server or trusted CDNs -- to minimize the risk of the javascript-package getting hacked.
  • Run js-packages through a checker like Snyk Vulnerability Database or retire.js to check for vulnerabilities -- especially if they're in any way related to user-input.

Other tips...

  • Be sure that your git repo is not accessible in your static-directory. You may have a a past version of something that yields credentials or server-information you wouldn't want shared.
  • Like javascript, load other files, especially images, locally. Folk have crafted malicious svg files that facilitate cross-site-scripting.

Resources...


(end)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment