# Arm 1: appended to CLAUDE.md (setups/p3-arm1/append/CLAUDE.md) ## Security rules These hold for every change. If a task seems to need an exception, stop and say so instead of making one. 1. Every endpoint and page says who may call it, on the endpoint itself: a named policy with `RequireAuthorization`, or `AllowAnonymous` for the few that are public. Data that belongs to one patient is read or changed only after checking that the caller is that patient or a staff member the policy allows. 2. No SQL from strings. Use LINQ, or `FromSqlInterpolated` and parameters. A column or sort order chosen by the caller is picked from a fixed list in code, never placed into the query. 3. A file name or path from a caller never reaches the file system. Files are stored under names the server generates and are looked up by id. 4. Request bodies bind to request types that list exactly the fields the caller may set. Entities are never bound from a request or returned as a response. No response, export or log contains a password hash, a token, a reset code or an Authorization header. 5. A URL supplied by a user is fetched only through the application's existing outbound guard (the one the avatar import uses), which refuses loopback and private addresses and follows no redirects. Never create another `HttpClient` for such a URL. 6. Text that a user typed is shown as text. No `MarkupString`, `Html.Raw` or raw HTML built from stored text; if formatting is wanted, the server produces the tags from a fixed list. 7. Forms and cookie-authenticated requests that change state keep antiforgery validation on. Never call `DisableAntiforgery()`. 8. Secrets come from configuration at run time. No key, password or token in source or in an `appsettings` file (obviously made-up values in tests excepted). 9. Tokens that grant access (password reset, invitations) are made with `RandomNumberGenerator`, stored hashed, valid once and for a short time measured with the injected `TimeProvider`. Answers do not reveal whether an account exists. 10. Passwords go through the existing password hasher only. Login and reset stay behind the existing attempt limit. 11. A redirect target that comes from a request must be a local path; check it before redirecting. 12. Uploads have a size limit and an allow-list of types, and are stored outside the web root. 13. In CSV or spreadsheet output, a cell that starts with `=`, `+`, `-` or `@` is prefixed with a single quote so it cannot run as a formula. 14. Errors sent to a caller are problem details without exception text. 15. Add a package only when the task needs it, pin its version, and run `dotnet list package --vulnerable --include-transitive` afterwards. # Arm 2: the same rules plus one closing section (setups/p3-arm2/append/CLAUDE.md, as appended) ## Security rules These hold for every change. If a task seems to need an exception, stop and say so instead of making one. 1. Every endpoint and page says who may call it, on the endpoint itself: a named policy with `RequireAuthorization`, or `AllowAnonymous` for the few that are public. Data that belongs to one patient is read or changed only after checking that the caller is that patient or a staff member the policy allows. 2. No SQL from strings. Use LINQ, or `FromSqlInterpolated` and parameters. A column or sort order chosen by the caller is picked from a fixed list in code, never placed into the query. 3. A file name or path from a caller never reaches the file system. Files are stored under names the server generates and are looked up by id. 4. Request bodies bind to request types that list exactly the fields the caller may set. Entities are never bound from a request or returned as a response. No response, export or log contains a password hash, a token, a reset code or an Authorization header. 5. A URL supplied by a user is fetched only through the application's existing outbound guard (the one the avatar import uses), which refuses loopback and private addresses and follows no redirects. Never create another `HttpClient` for such a URL. 6. Text that a user typed is shown as text. No `MarkupString`, `Html.Raw` or raw HTML built from stored text; if formatting is wanted, the server produces the tags from a fixed list. 7. Forms and cookie-authenticated requests that change state keep antiforgery validation on. Never call `DisableAntiforgery()`. 8. Secrets come from configuration at run time. No key, password or token in source or in an `appsettings` file (obviously made-up values in tests excepted). 9. Tokens that grant access (password reset, invitations) are made with `RandomNumberGenerator`, stored hashed, valid once and for a short time measured with the injected `TimeProvider`. Answers do not reveal whether an account exists. 10. Passwords go through the existing password hasher only. Login and reset stay behind the existing attempt limit. 11. A redirect target that comes from a request must be a local path; check it before redirecting. 12. Uploads have a size limit and an allow-list of types, and are stored outside the web root. 13. In CSV or spreadsheet output, a cell that starts with `=`, `+`, `-` or `@` is prefixed with a single quote so it cannot run as a formula. 14. Errors sent to a caller are problem details without exception text. 15. Add a package only when the task needs it, pin its version, and run `dotnet list package --vulnerable --include-transitive` afterwards. ## Before you finish When the tests pass, ask the security-reviewer subagent to review your change (`git diff`) and fix what it reports. Then run the tests again.