Secure design correction
Start with an explicit authorization matrix
For R1, a viewer may read a record only within their own team; an editor may read and update within their own team. Both require active membership. Unknown roles, missing records, inactive users and other teams are denied. A role is not a universal grant. The OWASP Authorization Cheat Sheet describes default denial and per-request authorization.
Keep input and output controls separate
R2 accepts an exact string of 1–80 Unicode code points with no whitespace-only value or C0/DEL control characters. This deliberately small classroom rule is not a universal business requirement or byte limit. For HTML text content use Python html.escape; do not reuse that output in JavaScript or URLs. A note such as A & B is legitimate and must remain readable after rendering. Validation alone does not ensure safe output.
Minimize the audit record
R3 records only the operation category and outcome in the model. In production, add reviewed actor and correlation identifiers, time and protected storage according to policy; never include raw notes or credentials by default. OWASP Logging discusses safe event handling and testing logging failures. The model returns an event for inspection; it does not persist one.
Review the dependency boundary
The toy source uses only the Python standard library. The dependency manifest records that fact, not a clean vulnerability scan. R4 asks for the actual runtime version, inventory, reviewed advisories and approval before any deployment. For this capstone there is no deployment. The NIST SSDF 1.1 is a selected secure-development reference, not a compliance claim.
Practice: implement the contract
Copy fixtures/portal_starter.py to a local working folder. Complete decide, valid_note and handle according to practice.en.md. Keep the starter fail-closed until protections are implemented. A denied or invalid update must never return a replacement record. Do not edit the original evidence or answer key.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Secure design correction — knowledge check
Apply capstone remediation principles to fictional scenarios.
Can a viewer update a same-team record?
Can an active editor read another team record?
Why encode HTML text?
What should the toy audit event contain?
Does no third-party package mean no dependency risk?