~/amex/write-ups
FREN
Alexandre K.@amex-32

Notifications

  • AvailableFor an internship or work-study, in the Alpes-Maritimes
  • New6 flags are hidden on this site: go find them
  • ContactThe contact form is live
Home/Write-ups

Write-ups

My security work, explained step by step.

Securing this portfolio

2026-10

How I audited and hardened this site: attack surface, HTTP headers, a strict CSP, server-side validation and leaked files.

CSPHTTP headersAPISQL

Context

This site is static (HTML, CSS and JavaScript generated by a Python script) and hosted on Vercel. Only one part runs on a server: the /api/scores and /api/ctf functions, which store the leaderboards in a MySQL database.

Goal: shrink what an attacker can exploit as much as possible, without breaking the site.

1. Mapping the attack surface

I listed everything that receives outside data: the two APIs (query parameters and JSON body), the contact form (sent to a third-party service) and what the browser loads (scripts, fonts, images).

I also looked at what the server returns unasked: the HTTP headers and the publicly reachable files.

2. Findings

Missing headers: apart from HSTS, no security headers at all. Nothing stopped the site from being framed (clickjacking) or an injected script from running.

Exposed source files: the build scripts and working files were served like pages, even though the repository is private. A classic information leak.

The API was already sound: parameterised SQL queries, database names taken from a fixed list, nicknames checked by a strict regular expression, bounded scores, per-IP rate limiting. Displayed data is inserted with textContent, never parsed as HTML.

3. Fixes

Strict Content-Security-Policy: scripts can only come from the site itself. The single inline script (picking the theme before first paint) is allowed by its SHA-256 hash, without unsafe-inline. Plugins are blocked, base-uri and form-action are locked down.

Other headers: frame-ancestors 'none' and X-Frame-Options: DENY against clickjacking, nosniff, a Referrer-Policy that only sends the origin to other sites, and a Permissions-Policy that turns off camera, microphone, geolocation and payment.

Internal files: excluded from the deployment, they are no longer served at all.

Regression test: on every change, a test checks that the hash of each inline script is in the CSP. Without it, editing one line of that script would silently break the theme.

4. What remains

Game scores are computed in the browser, so they can still be faked within the bounds. Truly preventing it would mean replaying the game on the server, which is overkill for a portfolio.

Rate limiting is per serverless instance. It is enough against simple spam; beyond that, it would take a rule in the host's firewall.

5. Checking

curl -I on the home page shows every header. While browsing the site, the browser console should show no CSP violation.

And to practise: six flags are hidden in this site. Open the terminal and type ctf to start.

GitHubLinkedInSite source code
© 2026 Alexandre K. · Tip: ⌘K or Ctrl+K opens search, ` opens the terminal.
Lighthouse (mobile, 29/10/2026) : Performance 88 · Accessibility 98 · Best practices 100 · SEO 100
amex · FL Studio
0:000:00