Buildfest Learn System DesignRead and experiment freely · Chapter activities stay in this tab
Practice librarySystem DesignSecurity deployment and engineering decisions

LESSON 10 • SYSTEM DESIGN

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.

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
  1. STEP 1IdentityValidate caller session
  2. STEP 2Object permissionScope query to allowed owner
  3. 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
  1. STEP 1Client inputIDs, amounts and strings
  2. STEP 2Server checksTypes, bounds and permissions
  3. 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
  1. STEP 1ExpandAdd compatible schema
  2. STEP 2TransitionSupport old and new clients
  3. 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
  1. STEP 1RequirementName the needed outcome
  2. STEP 2ChoiceState the selected approach
  3. 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
ConceptProtects or organizesExample
AuthenticationIdentity of a callerVerify the signed-in student
AuthorizationAllowed action on an objectCheck current ownership before downloading a submission
Input validationAccepted data shape and business rulesBound file size and permitted state transitions
Safe renderingHow data is presentedDisplay user text without executing its HTML
Expand and contractCompatible code/data changeAdd and backfill before removing an old column
Decision recordReasoning and consequencesRecord 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.