Armature Webdesk
Workflows

CSRF attack checks: from open folder to fix list

03
Header and form audit

Prepare the project folder

You own a small website and want a written list of what to fix before the next release. Copy the templates, the handler code, your server configuration and a saved block log into one working folder, ideally from a staging copy. Web security testing of your own site follows a checklist and ends with a fix list, and it is the goal here: one fix for each finding, and each fix as a diff you can read. Pick the files first. The file tools work in the chat's working folder, while Shell, web and SSH are not folder-bound, which is why you keep the work to your own systems yourself. Choose Plan only if you want to read every step before anything runs. The result is a fix list you can hand to a colleague, with the file name next to each item.

01

Open the folder

Choose a working folder that holds a copy of your site: templates, handler code, server configuration and a saved block log. Copy, never move. The agent lists the folder with list_dir, so you both start from the same picture.

02

Choose Ask first

Switch to Ask first so the agent pauses before every action that changes something, and you see the diff before any file is written. Each write needs your OK. Plan only is the stricter choice.

03

Let the agent look

Ask for a read-only pass. list_dir, grep and read_file collect the forms, cookie settings, header lines and CORS settings into one list, and nothing changes until you accept a diff, so the list becomes your checklist for the edits that follow.

04

Fix and test

Accept one diff at a time, run your own test command in Shell and read the exit code before you accept the next change. Stop at a failure. Read the output on the card and roll back to your backup copy before you try a smaller change.

A plain checklist file

headers-checklist.txt
# Headers checklist for my own site (staging copy first)
# Mark each line pass, fail or todo after a check
check 1: HSTS header is sent on HTTPS pages = todo
check 2: session cookie has SameSite set = todo
check 3: session cookie has Secure and HttpOnly = todo
check 4: X-Content-Type-Options is set to nosniff = todo
check 5: CSP runs in report-only mode first = todo
check 6: Referrer-Policy limits what is sent = todo
check 7: CORS allow-list names trusted origins only = todo
check 8: forms that change data carry a token = todo
check 9: server checks the token on every post = todo
check 10: block log read and rule changes noted = todo

headers-checklist.txt is a plain text file that the agent writes and updates in your working folder. Each line is one check on your own site, and the word at the end changes from todo to pass or fail as the agent reads the result of your header-check command. Hashes mark comments. Commit the file with the version-control skill, so every change to the list is tracked, and ask the agent to rerun the check whenever you want the marks refreshed from a new result.

Web security testing in four walkthroughs

Read the configuration first

Start with a read-only pass, so nothing can break. Ask the agent to read your server configuration copy and list every security header it sets. read_file loads the file into the chat, and grep searches it for Strict-Transport-Security, Content-Security-Policy and SameSite. An open source HTTP header analyzer prints what a live server sends, and your own header-check command can do the same through Shell, but the agent then also opens the file where each line belongs. Nothing is written. The card lists every header with its file name and line, and the checklist file gets one line per missing header. Compare both lists, mark what is missing and keep a backup of the configuration before you start the first edit. Plan only shows the same steps as a written plan if you prefer to read first.

Apply one header at a time

Take the first missing header from the checklist. edit_file adds it to the configuration copy and shows the diff, and Ask first pauses so you can read it. One header, one diff. A wrong value can break pages, so X-Content-Type-Options set to nosniff is a low-risk start, Content-Security-Policy goes in report-only form first, and HSTS comes only after HTTPS works everywhere on the site. Then Shell runs your configuration test command, and the card shows the real exit code. Deploy the file yourself, load the staging site in a browser, look at the console and keep the previous file as a backup, so that a rollback is a single copy. If a test fails, ask the agent to read the failing lines and propose a smaller change. Only then accept the next diff.

Review CSRF attack defences

A CSRF attack needs a logged-in browser that sends a request its user never meant, which is why a site must not trust cookies alone. Describe the defences to the agent in words and let it check them. grep and glob find the forms that change data, read_file opens each template and handler, and the findings list names every form without a token, a random value tied to the session. Asking for the password again is another layer. The agent also reports whether the session cookie has SameSite, Secure and HttpOnly. Fix one form first. edit_file proposes each missing piece as its own diff, you read it, accept it and run your test command in Shell, and then you submit the form once yourself on the staging copy to see that it still works.

Test CORS and read block logs

Understanding CORS in web development starts with one rule: a page may read a response from another origin only when that server allows it. The agent reads your allow-list with read_file, and http_get fetches a page of the staging copy so you can compare the result with the list. If the list names every origin, edit_file proposes a narrower one. For the block log, firewall logs are usually enough without switch logs, which describe the network and not the HTTP request. grep groups the blocked lines by rule. Rules can raise false alarms, so a new WAF rule first runs in log-only mode where the WAF offers one. Check the console first. A blocked request there is often the mechanism working, not a bug. Review each diff and keep the old rule file as a backup.

Armature Webdesk for Windows

Start with a read-only pass today

Download Armature Webdesk ↗