{"success":true,"name":"never-trust-client-side-values-for-money-roles-or-permission","description":"The frontend sends a price, role, discount, or permission to the server.","category":"ai-brimind","path":"ai-brimind/never-trust-client-side-values-for-money-roles-or-permission/SKILL.md","file":"SKILL.md","content":"---\nname: never-trust-client-side-values-for-money-roles-or-permission\ndescription: \"The frontend sends a price, role, discount, or permission to the server.\"\n---\n\n# Never Trust Client-Side Values for Money, Roles, or Permissions\n\n## When to use\nA request from the browser includes a value with security or money consequences (price, total, isAdmin, discount, user id), and the server uses it as-is.\n\n## Example request\nCart sends the total price and the server charges it → anyone edits the request and pays 1 instead of 100 — client-decided money. Request body includes role:'admin' on signup → attacker grants themselves admin — client-decided privilege. Hidden form field carries the userId to update → change the id, edit someone else's account — client-decided identity.\n\n## Instructions\nAct like a backend developer who assumes every request was hand-crafted by an attacker with full control of the payload, because it can be. For each incoming field, classify it: PREFERENCE (display name, chosen color — client may decide) versus AUTHORITY (price, total, discount, role, permissions, whose data is touched — server MUST decide). For authority fields: (1) recompute on the server — look up prices from the database and calculate totals there; the client's number is at most a display hint; (2) derive identity and role from the authenticated session/token, never from the request body; (3) check ownership before acting — does this session's user actually own the resource id in the request? Trace one hostile scenario per endpoint: 'what if this field is tampered?' If tampering changes money, access, or data ownership, the server-side check is missing. Only proceed once every authority value is server-derived and you can state where each one is recomputed or verified.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #1084\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}