Security deployment and engineering decisionsKnow who is asking. Decide what they may do.
Security deployment and engineering decisions. Learn the concepts, explore a model and defend your design.
10SYSTEM DESIGN
DEFINITION
Security defines and enforces who may do what across trust boundaries. Authentication establishes identity; authorization checks the permitted action on an object. Production engineering also makes configuration, change rollout and recovery manageable. A design must remain safe while requests, stored data and deployed code change at different times.
Check both identity and object access
STEP 1IdentityValidate caller session
STEP 2Object permissionScope query to allowed owner
STEP 3ResponseReturn only allowed fields
An object identifier supplied by the browser is not evidence of ownership.
CONCEPT 1
Know who is asking and what they may do
Two questions, not one
Authentication asks who the caller is. Authorization asks what that caller is allowed to do to this particular object. A student who is signed in does not automatically have permission to read every other student's receipt. Perform permission checks on the server for reads, changes, downloads, exports and background work.
Make ownership part of the query
An endpoint receiving an order ID should find that record under the correct user or tenant boundary, or require an explicit reviewer permission. A tenant is a separate customer or organization whose data must remain isolated. Hard-to-guess IDs reduce casual discovery but do not replace authorization. Hiding a button in the browser is a user-interface choice, not a security boundary.
Use safe defaults
Keep learner work private until the owner intentionally shares it. A signed download URL can grant limited access after permission has been checked, but its scope and expiry matter if it is forwarded. Logs and analytics should collect only needed information. Retention, export and deletion are part of the design, not merely legal text added after implementation.
CONCEPT 2
Treat data crossing a boundary as untrusted
Validation and safe rendering
An uploaded document, a diagram label and a request field all come from outside the server's trust boundary. Check type, size, allowed values and business rules. Use parameterized database queries. Render user text safely instead of treating it as executable HTML. A valid file extension is not proof that a file is safe or appropriate.
Secrets and encryption
Keep secret keys outside public source and expose them only to components that need them. TLS protects communication in transit; encryption at rest protects particular stored representations. Neither replaces an ownership check. A password should use an appropriate password-hashing design rather than reversible storage. Recovery, rotation and access to encryption keys need an operating plan.
Special danger from code and AI tools
Never run arbitrary learner code inside the main application or its normal worker. A reviewed isolated execution environment needs resource and network limits. In an AI-assisted system, retrieved documents and prompts can contain malicious instructions. Restrict tools and permissions, enforce document access before retrieval or disclosure, and require human authorization for consequential external actions. Model text is not a permission system.
Untrusted input crosses a server boundary
STEP 1Client inputIDs, amounts and strings
STEP 2Server checksTypes, bounds and permissions
STEP 3Trusted decisionsPrices and owner from server
Parameterized queries handle values safely; validation and business authorization remain separate duties.
CONCEPT 3
Deploy changes while old users are still active
A deployment changes a running system
A rolling release replaces instances gradually. A canary sends a small chosen portion of traffic to a new version before expanding. Blue-green keeps separate environments for a cutover. These strategies manage traffic and version exposure; none automatically repairs an incompatible database change. Readiness checks and draining protect requests during transitions.
Expand before removing
Suppose a database field needs replacing. First add a compatible new field. Deploy code that can coexist with the old version. Backfill existing rows in controlled batches and verify them. Switch the read path when ready. Remove the old field in a later release, after nothing still depends on it. This expand-and-contract approach creates a safer compatibility window.
Keep the recovery action realistic
Reverting a binary is useful only if the older code can still use the current schema and data. A destructive change may require forward repair or restoration instead. Define what signals stop a rollout, who decides and how users are protected. Containers package applications; Kubernetes can manage workloads, but a small application does not need it merely to look production-ready.
Expand before removing an old field
STEP 1ExpandAdd compatible schema
STEP 2TransitionSupport old and new clients
STEP 3ContractRemove after safe migration
Old application versions and active clients can overlap during deployment.
CONCEPT 4
Explain a design like an engineer
Use a clear order
Start with the user action and scope. State a small set of measurable quality needs and invariants. Estimate the workload with units. Draw a minimal request flow and data model. Then examine the important bottleneck, consistency question or failure. Finish by explaining security, signals, cost and a reasonable next improvement. This is a useful structure, not a script that should override an interviewer's direction.
Answer follow-ups with consequences
If asked why a queue exists, say which work can be delayed and how users learn it completed. If asked why a cache exists, state the repeated read and acceptable stale period. If asked why not microservices, discuss team and operational needs. A justified alternative can be valid even if it differs from this booklet's example. System design rarely has one universal correct drawing.
Make a decision record
A short architecture decision record explains context, considered options, the decision and its consequences. Add a trigger for revisiting it, such as measured database saturation or a new isolation requirement. State when you are uncertain and what test would resolve the uncertainty. The worked interviews that follow demonstrate this reasoning; they are original solutions, not official company answer keys.
Explain a decision through its consequence
STEP 1RequirementName the needed outcome
STEP 2ChoiceState the selected approach
STEP 3Trade-offDescribe cost and failure behavior
A useful design defense explains when the choice should be revisited, not only why it sounds attractive.
Key learning points
Derive ownership from trusted identity and enforce it on every protected path.
Validate and safely render learner files, text, diagrams and prompts.
Encryption does not replace an ownership check or a correct state transition.
Keep old and new application versions compatible with staged schema changes.
Choose services and operating tools from team, isolation and workload needs.
Compare the important ideas
Security deployment and engineering decisions: concepts and trade-offs
Concept
Protects or organizes
Example
Authentication
Identity of a caller
Verify the signed-in student
Authorization
Allowed action on an object
Check current ownership before downloading a submission
Input validation
Accepted data shape and business rules
Bound file size and permitted state transitions
Safe rendering
How data is presented
Display user text without executing its HTML
Expand and contract
Compatible code/data change
Add and backfill before removing an old column
Decision record
Reasoning and consequences
Record one rejected option and a revisit trigger
WORKED EXAMPLE
Change a field without breaking active clients
Add a compatible new field first. Deploy code that can handle the old and new representations. Backfill in controlled batches, verify data, then switch readers. Remove the old field only after its users and versions are retired. A code rollback works only while the current schema and records still support the old version; destructive mutations may require forward repair or restoration.
Further reading
Original teaching explanations by Buildfest Learn. Check these primary references for the underlying concepts and implementation details.
Student A requests Student B's private receipt. Decide which server-side check protects the data.
1A requests B's receipt
2Insufficient ownership check
3Private data may leak
Authentication or browser UI alone does not protect the receipt.
Apply object-level authorization on the server before returning the record. Never trust the client to choose its permitted owner ID.
Chapter review: two questions
Attempt both questions before opening the model answers.
Question 1
A signed-in student changes a submission ID in a download URL. Explain the checks needed before returning the artifact, including tenant and signed-URL concerns.
Reveal model answer
Find the object under current user/tenant permission or an explicit reviewer grant, not just by ID. Only then issue appropriately scoped, expiring access if using a signed URL. Review caching and forwarded-link exposure. Apply the same object checks to exports and background paths; identity alone is insufficient.
Question 2
An application must replace a database field while old instances still run. Give the rollout order and identify when reverting the code may stop being safe.
Reveal model answer
Add a compatible field, deploy coexistence logic, backfill and verify, switch reads, then contract after old versions retire. Once destructive changes remove data or structure old code expects, reverting the binary alone may be unsafe. Keep a tested forward-repair or restore option.
Answers stay in this tab. Download before leaving. This practice is not graded or saved to your account.