agentleFS
yaohuangguanyaohuangguan/agent-playbook/skills/secure-change/SKILL.md

secure-change

Skill1 starsChanged 2 days agoMITView on GitHub

Build or review code that handles login, permissions, user input, files, secrets, payments or personal data. Use this whenever a change adds an endpoint, a form, an upload, a query built from input, a webhook, a token or an admin action, even if security was not mentioned.

We split this skill into the rules it gives an agent

7 rules. About 0 are common, 6 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈6

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  • could be automatic: a setting could enforce it
  1. Distinctive:

    List what enters the system: Write down each value from outside your process: body, query, headers, cookies, files, webhooks, environment, …

    line 18
  2. Distinctive:

    Protect secrets: Read them from the environment or a secret store.

    line 44
  3. Distinctive:

    Protect state-changing requests: Check CSRF protection for cookie sessions.

    line 48
  4. Distinctive:

    Verify webhook signatures.

    line 49
  5. Distinctive:

    Fail closed: If a check errors or a dependency is down, deny the request.

    line 51
  6. Distinctive:

    Record sensitive actions: Write an audit record of who did what, without secrets or private content.

    line 54
  7. Very specific:

    Test it: Use the permission matrix in write-tests.

    line 57

≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Make a secure change

Most security bugs are ordinary omissions: a missing ownership check, a value trusted because it came from the client, a token in a log. This checklist exists to catch those, and is for defending your own software.

When to use

The change touches anything in the description. Use it for a review as well.

Steps

  1. List what enters the system. Write down each value from outside your process: body, query, headers, cookies, files, webhooks, environment, third-party responses. Treat all of it as untrusted.
  2. Check authentication. Each protected route must verify the caller on the server. Middleware only counts if this exact route goes through it.
  3. Check authorization on the resource. Being logged in is not enough. Query with the owner in the filter, such as WHERE id = ? AND user_id = ?, and take the user id from the session, never from the request body. Check the role for admin actions.
  4. Validate input at the boundary. Allow known good values. Check type, length, range and format. Limit list sizes, upload sizes and page sizes.
  5. Prevent injection. Choose by destination:

    DestinationSafe approach
    SQLParameters, never string building
    HTMLFramework escaping, no raw HTML from input
    ShellArgument arrays, no shell string
    File pathResolve it, then confirm it stays inside the allowed folder
    Outbound URLAllow-list hosts, block internal addresses
    RedirectAllow-list destinations
  6. Protect secrets. Read them from the environment or a secret store. Keep them out of code, logs, errors, URLs and client bundles. Store password hashes with a standard algorithm, and store only hashes of long-lived tokens.
  7. Protect state-changing requests. Check CSRF protection for cookie sessions. Verify webhook signatures. Add rate limits to login and other costly routes.
  8. Fail closed. If a check errors or a dependency is down, deny the request. Do not reveal internals in error messages.
  9. Record sensitive actions. Write an audit record of who did what, without secrets or private content.
  10. Test it. Use the permission matrix in write-tests. Add invalid inputs, and a canary secret that must not appear in responses or logs.
  11. Finish. Follow verify-and-report.

Stop and ask when

  • You would need to design your own crypto or session scheme.
  • A check would have to be weakened to meet the task.
  • You find an existing vulnerability. Report it, and do not include real exploit data or secrets in your report.

Common mistakes

Tempting moveWhy it failsDo this instead
Hide the button in the UIThe API is still openEnforce on the server
Take user_id from the requestAnyone can change itUse the session
Fetch by id, then check laterEasy to forget, and can leakFilter by owner in the query
Block known bad stringsAttackers find othersAllow known good values
Return the full database rowLeaks private columnsReturn named fields
Log the whole requestCaptures tokensLog named safe fields
Commit a test keyIt stays in historyUse environment variables

Example

# Weak: any logged-in user can read any invoice.
invoice = db.get("SELECT * FROM invoices WHERE id = ?", invoice_id)

# Strong: the owner comes from the session and is part of the query.
invoice = db.get(
    "SELECT id, total, status FROM invoices WHERE id = ? AND user_id = ?",
    invoice_id, session.user_id,
)
if invoice is None:
    return not_found()

Report

Inputs: <what enters, and how it is validated>
Access: <who can do this, and where it is enforced>
Secrets: <how they are handled>
Tests: <401, wrong owner, right owner, invalid input, canary>
Open risks: <anything not handled>

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.