Full stack engineer: Cross-Layer Contracts and Authorization
Original interview cases on trusted identity, authorization scope, data contracts, asynchronous effects, compatibility, and end-to-end evidence that protected operations behave as promised.
These prompts are original practice. They are not questions from a named employer or a live hiring loop.
1.A workspace API receives a verified session for workspace A and a JSON body naming workspace B. Its handler uses the body value to choose the authorization policy. What boundary should the design enforce?
Show answer and explanation
- Authorize any workspace when the session signature is valid.
- Prefer the body because it describes the latest client selection.
- Treat a syntactically valid workspace ID as trusted scope.
- Derive trusted scope and verify the requested target against it.
Answer: Derive trusted scope and verify the requested target against it.
Identity verification does not authorize an arbitrary target. Establish trusted actor context, then evaluate the action and resource within the requested workspace using authoritative relationships.
2.A backend accepts X-Actor-Id from a trusted gateway, but clients can also reach the backend directly. What makes that identity propagation unsafe?
Show answer and explanation
- A gateway-added header becomes trustworthy on every network path.
- The header is unsafe only when the actor ID is numeric.
- Using a longer header name authenticates the forwarding service.
- The backend cannot trust the header on an unauthenticated direct path.
Answer: The backend cannot trust the header on an unauthenticated direct path.
Authenticate and constrain the trusted hop, remove untrusted copies, and prevent bypass paths from supplying trusted identity assertions. Header presence alone does not establish provenance.
3.An object ID is globally unique. A handler checks membership in the URL's workspace but loads the object by ID without checking its actual workspace. What relationship is missing?
Show answer and explanation
- The number of characters in the URL's workspace ID
- A requirement that every member be an administrator
- The object's uniqueness across the database
- The loaded object's membership in the authorized workspace
Answer: The loaded object's membership in the authorized workspace
Two individually valid identifiers do not establish their relationship. Scope the lookup or check the authoritative object's workspace before authorizing the operation.
4.A request targets /folders/F/items/I. The actor may edit F, but I belongs to another folder. What should the server establish before editing I?
Show answer and explanation
- That I belongs to F and the actor may perform this action on I
- That both identifiers parse successfully
- That editing F automatically authorizes any item ID supplied after it
- That the folder was recently displayed in the browser
Answer: That I belongs to F and the actor may perform this action on I
Nested URL structure is a claim about a relationship, not proof of it. Verify parent-child membership and applicable action permissions using authoritative records.
5.A permission filter inspects a path before decoding, while the resource loader uses a differently normalized path. What contract is needed?
Show answer and explanation
- Authorization and resource resolution must refer to the same canonical target.
- A valid raw URL guarantees every parser resolves the same target.
- Permission checks should use whichever path is shorter.
- The browser's displayed path should override the server's resolution.
Answer: Authorization and resource resolution must refer to the same canonical target.
Different parsing or normalization can make the check and the operation refer to different resources. Establish consistent interpretation and reject ambiguous input at the boundary.
6.An API adds a new nonprivileged document status. An older client maps every unknown value to 'ready for approval.' What is the safer client contract?
Show answer and explanation
- Assume successful JSON parsing proves status compatibility.
- Preserve an explicit unknown state with restricted actions.
- Convert unknown values to whichever status appears first.
- Treat new values as the most permissive existing state.
Answer: Preserve an explicit unknown state with restricted actions.
Forward compatibility must preserve meaning. Unknown states need a defined fallback that does not invent readiness or privileges; the server still enforces valid actions.
7.A role mapper defaults unknown role strings to administrator to avoid breaking old clients. What should change?
Show answer and explanation
- Unknown authority must not grant administrative access.
- Only role names longer than ten characters should be rejected.
- The client should shorten unknown role strings.
- A valid token makes every contained role string authoritative and supported.
Answer: Unknown authority must not grant administrative access.
Unknown or unsupported authorization data should fail safely. Validate the allowed role model and avoid mapping uncertainty into elevated privilege.
8.A preferences API defines omitted enabled as 'keep current' and false as 'disable.' A serializer drops every falsy value. What contract defect results?
Show answer and explanation
- Every disabled value becomes an invalid JSON number.
- The server can reconstruct the intent from the current preference alone.
- Omission and false remain equivalent under this API.
- An explicit disable is silently converted into omission.
Answer: An explicit disable is silently converted into omission.
Falsy filtering loses a valid boolean intent. Serialization must preserve the distinction the API defines between an omitted field and an explicit false value.
9.A PATCH contract uses absence to keep a nickname, null to clear it, and a string to replace it. A form sends null for every untouched field. What should the client preserve?
Show answer and explanation
- All three cases should be collapsed to an empty string.
- Untouched fields must remain absent from the update.
- The server should treat every null as a replacement string.
- Null should mean 'keep' only when the browser omitted its label.
Answer: Untouched fields must remain absent from the update.
The three states encode distinct operations. Track edited fields and serialize the intended operation rather than turn untouched values into destructive clears.
10.An API represents an amount as integer minor units plus a currency code. A client forwards a display string such as '1,250' without its currency. What must the boundary require?
Show answer and explanation
- The assumption that grouping separators have one universal meaning
- The defined numeric units and currency, independent of display formatting
- A locale-specific string accepted without a currency
- Currency inferred solely from the browser locale
Answer: The defined numeric units and currency, independent of display formatting
Display formatting is not a machine contract for units or currency. Parse and validate against an explicit representation instead of silently interpreting ambiguous formatted text.
11.Two distinct 64-bit record IDs become the same value after a browser parses them as JavaScript numbers. What representation avoids this loss across the JSON boundary?
Show answer and explanation
- Rounding both IDs before comparison
- Sorting the parsed numbers to restore the original bits
- Exact string identifiers with defined validation
- A larger number of displayed decimal places
Answer: Exact string identifiers with defined validation
JavaScript's ordinary number type cannot exactly represent every 64-bit integer. A validated string representation can preserve an opaque identifier exactly across layers.
12.An actor may submit a draft but may not approve it. A general update endpoint accepts status='approved' because status is a writable database column. What should enforce the workflow?
Show answer and explanation
- A rule authorizing every transition after a successful login
- The order of status options in the client dropdown
- Server-side authorization of the requested state transition
- The fact that the column exists in the schema
Answer: Server-side authorization of the requested state transition
Writable fields and valid enum values do not establish permission to perform a business transition. Evaluate the actor, current state, requested action, and required conditions on the server.
13.The permission 'edit description' is checked once, then the handler also accepts a change to the record's owner. What contract is violated?
Show answer and explanation
- The database row's existence authorizes every field update.
- Different actions are being authorized as if they were the same operation.
- A successful field edit must always transfer ownership.
- Ownership is a client presentation detail.
Answer: Different actions are being authorized as if they were the same operation.
A broad update object can conceal distinct privileged actions. Define allowed changes for the authorized operation and handle ownership transfer through its own policy and invariants.
14.A public profile update binds a nested settings object directly to an internal model that also contains billing privileges. What is the safer request model?
Show answer and explanation
- A rule that nested JSON automatically inherits safe permissions
- An allowlist applied only to the top-level object name
- Every model field accepted if the client does not display it
- An explicit allowlist of editable fields, including nested paths
Answer: An explicit allowlist of editable fields, including nested paths
Mass assignment can occur below the top level. Map an external update contract to permitted fields rather than expose the full persistence model for automatic binding.
15.An API contract says project codes are ASCII case-insensitive. The permission index normalizes them, but the mutation lookup does not. What invariant should be tested?
Show answer and explanation
- Case-insensitive permission checks require case-sensitive business ownership.
- Both layers resolve the same normalized project identity.
- A code is authorized whenever one spelling passes validation.
- The mutation may choose a different project if its spelling is exact.
Answer: Both layers resolve the same normalized project identity.
Identity normalization must agree wherever the identity is used. A validation or permission check for one resolved project cannot authorize a mutation of another resolution.
16.A request normalizer lowercases every string, including an opaque capability token whose comparison is defined as case-sensitive. What should be changed?
Show answer and explanation
- Normalize only tokens that contain letters and digits.
- Lowercase the stored token to match every transformed request.
- Treat all case variations as the same capability.
- Apply normalization according to each field's semantics.
Answer: Apply normalization according to each field's semantics.
Human labels and opaque security values have different contracts. Preserve exact token bytes or characters as specified rather than applying a global text-cleanup rule.
17.A record moves to another workspace after an authorization check but before an update that uses only its ID. What must the write preserve?
Show answer and explanation
- A guarantee that checking once prevents concurrent movement
- The old workspace value copied from the browser
- The authorization-relevant relationship at the moment the write is accepted
- A rule allowing the update because the record ID did not change
Answer: The authorization-relevant relationship at the moment the write is accepted
Bind the check and write through an appropriate transaction, predicate, or version rule. A valid earlier relationship does not by itself authorize a later state-changing operation.
18.A browser switches from account A to B while A's data request is pending. The old response then fills B's active screen. What should response handling bind to?
Show answer and explanation
- The current account context and request generation
- The length of the returned list
- Only the response's arrival time
- A cache key containing only the page's route name
Answer: The current account context and request generation
An in-flight response belongs to the context that initiated it. Gate application of results and partition relevant caches so a late response cannot populate another account's view.
19.A cached browser menu still shows a revoked administrative action. The server correctly denies it. What should the client do?
Show answer and explanation
- Treat the denial as permission to trust the cached role instead.
- Handle denial and refresh its authority-related state.
- Keep retrying because the menu proves authorization.
- Convert the request into a different privileged endpoint.
Answer: Handle denial and refresh its authority-related state.
Cached affordances can become stale. The server remains authoritative, and the client should reconcile current permissions without bypassing the denial or entering an unbounded retry loop.
20.An authorization cache contains grants indefinitely and its key omits policy revision. The system promises revocation on the next protected action. What must the design address?
Show answer and explanation
- A rule treating the first cached grant as permanent ownership
- Cache freshness or invalidation sufficient to meet that revocation promise
- Only whether cached lookups are fast
- A guarantee that signed sessions invalidate every policy cache
Answer: Cache freshness or invalidation sufficient to meet that revocation promise
A revocation guarantee constrains how cached authority can be used. Check current policy or implement bounded, correctly invalidated state consistent with the promised enforcement boundary.
21.A live subscription was authorized when opened. The policy requires a permission removal to stop later protected events, but the connection stays open. What enforcement boundary is missing?
Show answer and explanation
- Reevaluation or invalidation of the stream's continuing authority
- A requirement to disconnect only after the next deploy
- A rule that read-only events need no resource authorization
- A guarantee that connection authentication grants permanent access
Answer: Reevaluation or invalidation of the stream's continuing authority
An authorized connection is not an unlimited continuing grant. Implement a policy-consistent way to stop or filter delivery when the relevant authority changes.
22.A search API filters unauthorized rows from results but computes facet counts from every workspace. What should the response contract require?
Show answer and explanation
- Assume a filtered result list makes every accompanying aggregate safe.
- Expose all counts because they are numeric rather than text.
- Apply the relevant visibility scope to derived counts as well.
- Hide only the unauthorized row titles.
Answer: Apply the relevant visibility scope to derived counts as well.
Counts and facets can reveal information about hidden records. Apply the intended access policy to derived information, not only to the primary row list.
23.An actor may read a case's public summary but not its internal annotation. The API authorizes the case and serializes every column. What is still needed?
Show answer and explanation
- A longer object identifier for the same response
- A rule allowing every column after any object-level read check
- A hidden annotation panel in the browser
- Field-level output projection consistent with the actor's rights
Answer: Field-level output projection consistent with the actor's rights
Permission to access an object does not imply permission to every attribute. Build the allowed representation on the trusted side of the boundary.
24.A query authorizes access to a shared board, then resolves linked private personnel records without additional checks. What should the resolver design preserve?
Show answer and explanation
- A guarantee that query nesting implies inherited authorization
- The assumption that an internal resolver cannot expose external data
- The applicable access rule for each protected linked resource
- A rule that a public parent makes all linked objects public
Answer: The applicable access rule for each protected linked resource
A valid parent relationship can lead to resources governed by different policies. Resolve links with the appropriate actor context and resource-specific permissions.
25.A reusable batch loader caches record 17 across requests, although different tenants each have a local record 17. What should its cache identity or lifetime reflect?
Show answer and explanation
- A rule that batching automatically prevents cross-request leakage
- A shared loader reused without tenant-aware identity
- Only the integer record ID
- Tenant and other relevant access context, or safe request scoping
Answer: Tenant and other relevant access context, or safe request scoping
A cache must not collapse identities or authority contexts that the data model keeps distinct. Request scoping and appropriately complete keys prevent unsafe reuse.
26.A download link grants bearer access until expiry even after its user's role is revoked. The product promises immediate revocation of future downloads. What must change?
Show answer and explanation
- The download enforcement path must satisfy the stronger revocation contract.
- A claim that a signed link consults live roles automatically
- The assumption that hiding the link invalidates an issued bearer grant
- Only the link's display label
Answer: The download enforcement path must satisfy the stronger revocation contract.
A self-contained bearer URL can outlive the authority used to issue it. Use an appropriate checked access path or other effective revocation mechanism, or change the documented guarantee.
27.An export policy requires current access when execution starts. A queued job trusts a submitted isAdmin=true field instead of authoritative permissions. What should the worker evaluate?
Show answer and explanation
- The assumption that all roles are frozen at submission forever
- Current authority under the stated job-execution policy
- A rule that queue delivery authenticates every payload field
- Only the browser's submitted role flag
Answer: Current authority under the stated job-execution policy
Job payloads do not define their own authority. Use trusted identities, validated target scope, and the policy governing execution, including when rights must be checked.
28.An upload is scanned, then a different object version is attached to the record using the same storage key. What should finalization bind together?
Show answer and explanation
- Only the storage key's filename
- The approved scan result and the exact object version attached
- A browser flag saying the current file was checked
- The claim that a key once scanned remains safe after replacement
Answer: The approved scan result and the exact object version attached
A check applies to the content it examined. Bind validation and attachment to an immutable version or equivalent verified identity rather than a mutable name alone.
29.A paged export's contract requires current permission for each batch. The user loses access after batch one, but later batches use only the original approval. What should be enforced?
Show answer and explanation
- The assumption that an initial page authorizes all future resource states
- The specified current-permission check for subsequent batches
- A rule completing every export regardless of later revocation
- A client timer that hides the progress bar after access changes
Answer: The specified current-permission check for subsequent batches
Long-running work needs an explicit authorization lifetime. Here the stated policy requires later checks; the initial authorization is not sufficient for subsequent batches.
30.A worker correctly creates a private report. A separate download endpoint checks only whether the report file exists. What is missing?
Show answer and explanation
- Authorization to retrieve that particular stored artifact
- The assumption that private generation guarantees private delivery
- Proof that the worker ran successfully
- A requirement that reports use an unguessable extension
Answer: Authorization to retrieve that particular stored artifact
Creating a file through an authorized workflow does not protect every later retrieval path. Enforce access when serving the artifact under the applicable policy.
31.A hidden-resource policy requires unauthorized callers not to learn whether a record exists. An error includes its title and owner after denying access. What should the error contract preserve?
Show answer and explanation
- The policy's information-disclosure boundary
- A rule that an error status makes its body nonsensitive
- The assumption that denial messages are visible only to administrators
- The complete record to help the caller debug
Answer: The policy's information-disclosure boundary
A denied operation can still disclose protected data through its response. Use a consistent permitted error representation without exposing resource details the caller cannot read.
32.A service executes a user's delegated action, but the audit trail records only the service account. What information is lost?
Show answer and explanation
- The fact that a server process existed
- A guarantee that service authentication identifies the human initiator
- The initiating actor and delegation context
- The permission grant itself as a complete human identity
Answer: The initiating actor and delegation context
An executor and an initiating principal are different identities. Preserve trustworthy delegation and action context so the record explains whose authority was used and what the service did.
33.A support session is delegated read access as another user. A shared controller treats that session as full impersonation and allows writes. What should constrain the action?
Show answer and explanation
- The explicit rights of the delegation as well as the target policy
- A rule that viewing as someone grants every action they could take
- Only the target user's normal capabilities
- The presence of a support-session banner
Answer: The explicit rights of the delegation as well as the target policy
Delegation can be narrower than the target identity's ordinary rights. Enforce the granted purpose and scope on the server rather than converting a read-only support workflow into unrestricted impersonation.
34.A scheduled cleanup is a system-owned action under a service policy. Its worker instead depends on a former employee's browser session to run. What should the identity model distinguish?
Show answer and explanation
- The assumption that copying the old session extends its validity
- System authority from an employee's interactive session
- A guarantee that scheduled jobs require no authorization
- A rule making every service task an administrative user login
Answer: System authority from an employee's interactive session
A durable system task needs an appropriate service identity and bounded policy. It should not accidentally inherit its lifetime or privileges from an unrelated human browser session.
35.Two token types share a signing key: one is for account login, the other for a narrowly scoped export. A service checks only the signature. What must it also validate?
Show answer and explanation
- A rule that a shared key makes token purposes interchangeable
- The assumption that every valid token grants export rights
- Only whether the signature text has the expected length
- The expected token purpose, audience, and other required claims
Answer: The expected token purpose, audience, and other required claims
Cryptographic validity is only part of token validation. Bind acceptance to the token type, recipient, issuer, lifetime, and authorized operation defined by the protocol.
36.A signed delegation permits editing a description but not granting access. A handler uses the delegator's broader administrator role to add a collaborator. What should the permission calculation respect?
Show answer and explanation
- The narrower delegation scope
- The target user's ordinary maximum privilege
- Only the delegator's maximum available role
- A rule that delegation expands to every right of its issuer
Answer: The narrower delegation scope
Possessing broad authority does not mean every delegation conveys it. Evaluate the requested action against the actual grant and other applicable constraints.
37.A request has a valid session cookie for account B but supplies a CSRF token bound to account A's session. What should the check establish?
Show answer and explanation
- A rule accepting any well-formed token from the application
- That the token belongs to the relevant authenticated session
- That either account has previously obtained some token
- Only that a CSRF field is nonempty
Answer: That the token belongs to the relevant authenticated session
A token-based CSRF defense needs the required binding and validation, not mere token presence. A token from another session does not satisfy the stated session-bound design.
38.An origin allowlist is derived from the request's untrusted forwarded host. What should define the trusted comparison origin instead?
Show answer and explanation
- The caller's chosen forwarded host value
- A rule accepting every origin when a proxy is present
- The request's Origin copied into the expected value
- Configured or authenticated deployment context
Answer: Configured or authenticated deployment context
A check is circular if the caller can choose its expected value. Use trusted configuration and correctly constrained proxy metadata for the application's origin policy.
39.A fetch client expects a structured API authentication error, but middleware redirects it to an HTML login page. What should the cross-layer contract address?
Show answer and explanation
- The assumption that every final HTTP 200 contains the requested JSON
- A rule treating a followed redirect as proof the API operation succeeded
- A requirement to parse the login HTML as a successful data object
- API authentication responses and explicit client sign-in handling
Answer: API authentication responses and explicit client sign-in handling
Redirect-following can produce a login page instead of API data. Define how API callers detect authentication failure and initiate the appropriate interactive flow.
40.A client sends If-Match: W/"rev9" to protect a state-changing request. The server treats the weak tag as a strong match. What is the standards issue?
Show answer and explanation
- If-Match is defined only for cacheable GET requests.
- Every weak tag proves byte-for-byte equality.
- Weak and strong tags are interchangeable for every precondition.
- If-Match entity-tag comparisons require strong comparison.
Answer: If-Match entity-tag comparisons require strong comparison.
HTTP requires strong entity-tag comparison for If-Match. A weak validator does not satisfy that requirement merely because its opaque label resembles the current tag.
41.A form reorders its rows while validation is pending. Server errors refer only to the old array indices and appear beside different rows. What should error correlation preserve?
Show answer and explanation
- The submitted row identity and relevant request generation
- Only the order in which errors arrive
- A rule assigning every error to the first editable field
- Current row labels even when the submitted row moved
Answer: The submitted row identity and relevant request generation
Errors belong to a submitted state. Stable row identity and request correlation prevent an error from being applied to a different row after local edits or reordering.
42.A client decides whether to retry by searching a translated error message for the word 'busy.' What would make that contract more robust?
Show answer and explanation
- A rule retrying every response containing any text
- A stable machine-readable error code with defined retry semantics
- The assumption that HTTP success and domain success always coincide
- An English message permanently forced on every user
Answer: A stable machine-readable error code with defined retry semantics
Human messages can change for localization or clarity. Use a documented machine contract for control flow while keeping a suitable message for people.
43.An endpoint successfully returns HTTP 204 with no body. A shared fetch wrapper always parses JSON and reports failure. What should the wrapper respect?
Show answer and explanation
- A rule treating empty bodies as authentication failures
- A requirement to invent a JSON body for every 204 response
- The response's defined bodyless success contract
- The assumption that every successful method creates a resource
Answer: The response's defined bodyless success contract
A 204 response has no content to parse. Handle status and body semantics correctly instead of converting a successful operation into a client-side parsing error.
44.An API promises a durable job receipt, but returns 'accepted' before recording the job or confirming a durable enqueue. A crash loses the task. What should acknowledgment depend on?
Show answer and explanation
- The receipt identifier being generated in browser memory
- A delay long enough that crashes seem unlikely
- The persistence boundary promised by the acceptance contract
- Only completion of request-body parsing
Answer: The persistence boundary promised by the acceptance contract
Acceptance is a defined state transition, not proof of eventual completion. If a receipt promises durable acceptance, cross that durable boundary before acknowledging it and make subsequent status discoverable.
45.A client times out after submitting an approval. The server may already have committed it. Which outcome model avoids falsely labeling the operation as definitely absent?
Show answer and explanation
- Represent an unknown outcome and reconcile using the operation identity.
- Show success solely because the request was sent.
- Treat every timeout as proof that no state changed.
- Generate unrelated approvals until one returns quickly.
Answer: Represent an unknown outcome and reconcile using the operation identity.
A missing response does not establish whether the operation committed. Use a suitable operation identity, status lookup, or safe retry contract to resolve uncertainty without inventing a definite outcome.
46.An idempotency response cache uses only a caller-supplied key across every account. Two accounts choose the same key and one receives the other's result. What scope is missing?
Show answer and explanation
- Only the selected idempotency string without actor scope
- Only the key's display capitalization
- A rule that client-selected keys are globally unique by definition
- The relevant principal, tenant, and operation identity
Answer: The relevant principal, tenant, and operation identity
A key's scope must match the operation and response isolation rules. A shared cache must not treat unrelated callers' requests as the same authorized operation merely because their strings match.
47.The policy requires current permission even when replaying a completed request. A handler returns a cached idempotent result before authorization. What must change?
Show answer and explanation
- Delete all idempotency support from the protocol.
- Assume the original request grants permanent read access.
- Treat possession of an operation key as an administrator role.
- Enforce the required access check before disclosing the cached result.
Answer: Enforce the required access check before disclosing the cached result.
Idempotency and authorization answer different questions. Reusing a result must still satisfy the stated disclosure policy rather than bypass current permission checks.
48.A client reuses one idempotency key for two requests with different semantic payloads. The API contract forbids this reuse. What response behavior preserves that rule?
Show answer and explanation
- Execute both and keep only the first response.
- Choose whichever payload finishes validation first.
- Reject the conflicting reuse instead of silently treating it as the first operation.
- Return the old result while claiming the new payload was applied.
Answer: Reject the conflicting reuse instead of silently treating it as the first operation.
Bind the key to the appropriate request identity and payload semantics. Conflicting reuse needs an explicit outcome; silently substituting an earlier operation misrepresents what happened.
49.A response adds an optional diagnostic field that does not change existing field meanings. An older decoder rejects every unknown property. What compatibility decision is needed?
Show answer and explanation
- An explicit consumer policy for compatible additive fields
- A guarantee that every extra field changes the API's security model
- A requirement that optional response metadata replace required fields
- A rule ignoring validation of all known fields
Answer: An explicit consumer policy for compatible additive fields
Define which additions clients can tolerate while still validating required fields and security-relevant semantics. Strict unknown-property rejection can make otherwise compatible additions operationally breaking.
50.A new UI assumes displayLabel is always a string, but older stored rows legitimately lack it. What must the cross-layer model account for?
Show answer and explanation
- A rule converting all missing records into empty database tables
- The actual transitional data states and a defined handling rule
- A guarantee that deploying a new schema rewrites every old row
- Only the type annotation compiled into the new UI
Answer: The actual transitional data states and a defined handling rule
Deployed code and stored data can be at different transition stages. Model, backfill, or otherwise handle valid older states before relying on a stronger invariant.
51.Server-rendered HTML hides a credential field visually, but the page passes the full account object into a hydrated client component. What should the data boundary change?
Show answer and explanation
- Rename the credential property before serialization.
- Assume server rendering prevents serialized props from reaching the browser.
- Hide the credential with a second CSS rule.
- Pass only the permitted client-visible projection.
Answer: Pass only the permitted client-visible projection.
Data sent for hydration is client-visible even if no element displays it. Construct a safe projection before crossing the server-to-browser boundary.
52.A shared request module includes a private service credential and is imported by browser code. What separation is needed?
Show answer and explanation
- Hide the credential in an unused client-side constant.
- Keep privileged credentials and calls behind a trusted server interface.
- Assume an import is private because its filename contains 'server'.
- Minify the credential before bundling.
Answer: Keep privileged credentials and calls behind a trusted server interface.
Module names and minification do not protect values shipped to a browser. Enforce the server/client boundary and expose only authorized application operations to clients.
53.A quantity is stored to three decimal places. A form rounds it for display, then sends that rounded value when only a note was edited. What should the update contract preserve?
Show answer and explanation
- A rule rounding every database value after any note change
- A full replacement built solely from formatted display values
- The assumption that displayed precision defines stored precision
- The unedited quantity's authoritative precision
Answer: The unedited quantity's authoritative precision
Formatting a display should not silently mutate unedited data. Preserve the authoritative value or send only intended field changes using the defined precision contract.
54.A shared cache stores a permission-filtered 404 under a resource path alone. Its owner later receives that cached denial. What should cache design distinguish?
Show answer and explanation
- A rule that a 404 can never be affected by authorization
- A guarantee that negative responses are identical for all callers
- Responses whose meaning depends on the caller's authority
- A cached denial treated as caller-independent by status alone
Answer: Responses whose meaning depends on the caller's authority
A negative response can be contextual. Prevent reuse across authority contexts when the policy or lookup result differs, and apply appropriate cache controls for the representation.
55.A due date is defined as a calendar date without a time zone. The client converts it to an instant and displays the previous day in some zones. What semantic distinction was lost?
Show answer and explanation
- Adding more timestamp precision restores the original date semantics.
- A date-only value is not an absolute timestamp.
- Every date must denote midnight UTC.
- The user's time zone determines a different stored due date.
Answer: A date-only value is not an absolute timestamp.
A calendar date and an instant are different data types. Preserve the specified date semantics across storage, transport, and display instead of adding an unintended time-zone conversion.
56.A signed pagination cursor was issued for one tenant and filter. The API accepts it with another filter and returns an incoherent continuation. What must cursor validation bind to?
Show answer and explanation
- Only the fact that the signature is valid
- A rule that all signed cursors can continue any query
- The requested page's position in the browser history
- The query scope and ordering contract it continues
Answer: The query scope and ordering contract it continues
A cursor's integrity does not make it meaningful for every request. Validate the relevant tenant, filter, ordering, and continuation context defined by the API.
57.Two login flows are open in one browser. A callback is matched to whichever flow was started most recently rather than its own recorded state. What should callback handling preserve?
Show answer and explanation
- Only the order in which callbacks arrive
- A rule that all successful logins in one browser share the same intent
- The binding to the specific initiating authorization transaction
- The account name displayed in the currently visible tab
Answer: The binding to the specific initiating authorization transaction
Correlate an authorization response with its intended transaction and required protocol context. Concurrent flows must not overwrite the identity or intent associated with one another.
58.A post-login redirect parameter can name any destination. What should the application define before following it?
Show answer and explanation
- An allowed destination policy validated at the redirect boundary
- A decision based only on whether the URL contains the site's name
- A guarantee that a successful login makes every destination trusted
- A rule accepting any URL supplied before authentication
Answer: An allowed destination policy validated at the redirect boundary
Authentication does not validate a destination supplied by a caller. Apply a suitable destination policy and avoid weak string checks that confuse an allowed destination with an arbitrary URL.
59.A privileged action expires at a server-defined time. A slow browser clock keeps its button enabled afterward. Which component should decide whether the action remains authorized?
Show answer and explanation
- The assumption that a client timer extends the grant's expiry
- The trusted server-side time and policy check
- The cached client countdown as the grant's authority
- The browser's enabled state
Answer: The trusted server-side time and policy check
A client timer is an affordance, not the authority for a time-limited grant. Enforce expiry in the trusted decision path using the system's specified time assumptions.
60.An API returns 403 because a current user lacks permission. A global client interceptor refreshes credentials and retries forever. What distinction should it preserve?
Show answer and explanation
- Refreshing any valid session grants the missing permission.
- Insufficient authority is different from an expired credential.
- Every denial means the password must be changed.
- An infinite retry loop is required to maintain session continuity.
Answer: Insufficient authority is different from an expired credential.
Authentication renewal cannot generally supply an unauthorized action's missing rights. Classify errors under the API contract and handle a permission denial without unbounded credential refreshes.
61.An endpoint validates a JSON request model, but an alternate form-encoded parser reaches the same mutation with unvalidated fields. What must the boundary ensure?
Show answer and explanation
- Every accepted representation reaches equivalent validation and authorization.
- A content-type header proves the submitted fields are trusted.
- Only JSON requests need business-rule validation.
- Form fields should bypass validation because browsers generated them.
Answer: Every accepted representation reaches equivalent validation and authorization.
Constrain supported representations and validate the actual parsed model used by the operation. An alternate parser must not create an unprotected route around the intended contract.
62.A gateway validates the first occurrence of a repeated JSON member, while the backend uses the last. What should the API do about this ambiguity?
Show answer and explanation
- Treat the shortest member value as authoritative by convention.
- Authorize one interpretation and execute the other.
- Reject duplicate members or otherwise enforce one consistent interpretation.
- Assume every JSON parser chooses the same occurrence.
Answer: Reject duplicate members or otherwise enforce one consistent interpretation.
Duplicate JSON names have inconsistent handling across implementations. A security-relevant boundary needs an unambiguous, consistently applied interpretation rather than parser-dependent authority.
63.A JSON contract requires an integer pageSize from 1 to 100. The server accepts the string '12extra' because a permissive conversion yields 12. What validation is missing?
Show answer and explanation
- A rule accepting any text with a numeric prefix
- Only a range check after partial string conversion
- The assumption that a successful conversion proves contract compliance
- Validation of the original value against the defined type and range
Answer: Validation of the original value against the defined type and range
A partial conversion can discard invalid input and hide a type mismatch. Validate the accepted representation and full value according to the API's explicit contract.
64.An export request must specify one authorized collection. A blank collection field is converted to an unfiltered query over all collections. What should the contract require?
Show answer and explanation
- Treat absence as permission to export everything.
- Reject or explicitly handle missing scope without expanding authority.
- Assume a blank UI selection is an administrative request.
- Use the largest collection as an implicit default.
Answer: Reject or explicitly handle missing scope without expanding authority.
Missing scope must not silently become broader access. Define an explicit safe meaning and validate the requested collection against the caller's authority.
65.Generated client types declare a request role as 'viewer' or 'editor.' A developer removes runtime validation because the SDK compiles. What boundary remains unprotected?
Show answer and explanation
- Every HTTP caller must use the published SDK.
- Compile-time types authenticate a request's source.
- Requests can arrive outside the generated client's type system.
- The database can accept only values that appeared in TypeScript.
Answer: Requests can arrive outside the generated client's type system.
Static types help supported callers but do not constrain arbitrary network input. Validate and authorize on the trusted runtime path.
66.A batch protocol returns HTTP 200 with a documented per-item outcome union. The UI marks every item successful without reading those outcomes. What should it use?
Show answer and explanation
- Only the envelope's transport status
- A rule treating any syntactically valid response as all-success
- The number of rows the user selected
- The defined outcome of each requested item
Answer: The defined outcome of each requested item
Transport success and each domain operation's outcome are distinct in this contract. Report the per-item results rather than inventing success for denied or failed items.
67.A worker returns batch results in completion order. The UI attaches them to inputs by array position, although each result has an operation ID. What should correlation use?
Show answer and explanation
- The operation ID defined by the batch contract
- The assumption that parallel work always finishes in submission order
- Only the relative response position
- The order of the currently rendered rows
Answer: The operation ID defined by the batch contract
Concurrent completion order need not match submission order. Bind results to their intended operations using the contract's stable identity.
68.A pooled database connection retains tenant context from its previous request. Row-level policies read that context. What must connection handling guarantee?
Show answer and explanation
- Correct tenant context with an appropriately bounded lifetime and reset
- Only that the application process knows the current tenant
- A guarantee that pooling clears arbitrary session state automatically
- A rule trusting whichever tenant used the connection first
Answer: Correct tenant context with an appropriately bounded lifetime and reset
Database enforcement is only as correct as its trusted context. Set and scope context safely, including transaction and pool reuse behavior, so one request cannot inherit another tenant's authority.
69.An authorization service times out and the handler's catch block returns allow=true. What should failure handling preserve?
Show answer and explanation
- The previous user's successful result for any new caller
- The assumption that service failure implies caller permission
- A rule granting broader access as dependency health worsens
- A safe access decision consistent with the protection policy
Answer: A safe access decision consistent with the protection policy
An inability to establish authorization is not evidence of a grant. Fail safely and expose an appropriate availability outcome without silently converting uncertainty into privilege.
70.A socket is authenticated once, then accepts commands targeting arbitrary document IDs without action checks. What should command handling evaluate?
Show answer and explanation
- A rule that persistent connections make resource checks unnecessary
- Only whether the connection's handshake succeeded
- The number of messages previously sent on the socket
- The actor's permission for each requested action and target
Answer: The actor's permission for each requested action and target
Connection authentication establishes an identity at a boundary. Each protected command still needs the applicable action and resource authorization.
71.Moving a document requires removing it from one workspace and creating a reference in another. The server checks rights only at the source. What is missing?
Show answer and explanation
- The required destination authority and the move's joint invariants
- A rule that any source editor can write to every destination
- Proof that the source document has a valid ID
- The client confirmation dialog's wording
Answer: The required destination authority and the move's joint invariants
A cross-scope operation can require permissions on multiple resources. Enforce the full move policy and appropriate consistency rather than authorize only its first half.
72.A product promises no application-managed private offline records after logout, but its local database keeps them. What must logout handling include?
Show answer and explanation
- Only deletion of the server session cookie
- A guarantee that network logout clears every browser database
- The relevant persistent client stores under the stated offline policy
- The assumption that offline copies inherit server expiry automatically
Answer: The relevant persistent client stores under the stated offline policy
Application-managed local data has its own lifetime. Include those stores in the defined logout and account-isolation behavior; server session termination alone does not remove local copies.
73.A webhook signature authenticates a producer. Its payload names a customer account outside that producer's configured integration scope. What must the receiver verify?
Show answer and explanation
- Only that the message was signed by some known producer
- The payload's customer display name as proof of ownership
- A rule that a signature authorizes all accounts mentioned in its payload
- The event's allowed account mapping and business scope
Answer: The event's allowed account mapping and business scope
Authenticating a sender does not grant unlimited business authority. Bind the event to the configured integration and authorized target relationships before applying effects.
74.A record is at revision 12 when a delayed integration event for revision 10 arrives. The integration contract forbids older events from overwriting newer state. What should application enforce?
Show answer and explanation
- The version-ordering rule before applying the event
- The latest arrival as the latest business version
- A rule that signed events are always newer than stored state
- The event's processing duration as its version
Answer: The version-ordering rule before applying the event
Transport arrival and business revision order are different. Apply the specified version rule and handle duplicates or stale events without rolling state backward.
75.An unauthenticated caller supplies a stale If-Match value. The server reveals the current validator before doing normal access checks. What should the request evaluation preserve?
Show answer and explanation
- Normal request checks before applicable precondition evaluation
- A requirement to reveal current state for every conditional request
- The assumption that a failed precondition permits record disclosure
- A rule that validators replace authentication
Answer: Normal request checks before applicable precondition evaluation
HTTP preconditions do not bypass normal request checks. Access failures should not be turned into a path for learning protected resource metadata by evaluating and disclosing validators first.
76.A new private folder is visible between its creation and its owner's grant being stored. The reader interprets a missing ACL as public access. What invariant is required?
Show answer and explanation
- The owner's later grant retroactively protects earlier reads.
- A delay before the browser lists the folder is sufficient.
- Incomplete authorization state must not expose the folder.
- Every object without an ACL should inherit public access.
Answer: Incomplete authorization state must not expose the folder.
Use a creation and authorization design that preserves confidentiality, including safe defaults for incomplete state. Later repair does not undo data already disclosed during a creation gap.
77.A batch creates a parent and then a child that references it. The parent creation fails, but the client still sends the child with a temporary parent identifier. What must the batch contract define?
Show answer and explanation
- The assumption that child creation can infer the parent's intended content
- A rule treating any temporary identifier as a stored parent
- Dependency handling and valid identity resolution before dependent effects
- A guarantee that array order establishes successful creation
Answer: Dependency handling and valid identity resolution before dependent effects
Dependent operations need defined success and identity relationships. Reject, defer, or atomically handle dependent work according to the contract instead of creating references to a failed operation.
78.Allowed actions are the intersection of actor {read, edit, grant}, delegation {read, edit}, and resource {read}. Which actions survive the stated rule?
Show answer and explanation
- edit only
- read and edit
- read only
- read, edit, and grant
Answer: read only
The action must appear in all three sets. Only read is common to the actor, delegation, and resource scopes; unioning the sets would incorrectly broaden the grant.
79.A policy allows an action exactly when active AND (owner OR shared). A user is inactive but owns the resource. What does the policy return?
Show answer and explanation
- Defer solely to whether shared is true
- Allow if the browser cached an active state
- Deny
- Allow because ownership overrides active
Answer: Deny
The active condition is required for either ownership or sharing. False AND any value is false; ownership does not override the explicitly stated condition.
80.Approval requires two distinct people. One person approves from two sessions, and the counter treats session IDs as separate approvers. What identity should the rule count?
Show answer and explanation
- Distinct client IP addresses
- Distinct request timestamps
- Distinct browser sessions
- Distinct authorized people under the approval policy
Answer: Distinct authorized people under the approval policy
Session, device, request, and person identities are not interchangeable. Enforce the specified distinct-principal rule and any additional approval conditions at the trusted decision point.
81.A contract limits names by Unicode code points. A browser validator instead counts UTF-16 code units, rejecting some valid supplementary characters. What must the layers agree on?
Show answer and explanation
- The assumption that any string-length function implements the same contract
- The specified unit and rule for measuring text length
- Only the visible width of the input box
- A rule that all Unicode characters occupy one UTF-16 unit
Answer: The specified unit and rule for measuring text length
Code points, code units, grapheme clusters, and bytes are different measures. Use the defined measure consistently rather than assume one runtime's length operation matches every text contract.
82.An API test suite exercises only the newest client against the newest server. The product supports older clients during rolling deployments. What coverage is missing?
Show answer and explanation
- The supported client/server version combinations and relevant data states
- A guarantee that the same schema filename proves compatibility
- A rule requiring all clients to upgrade in one instant
- Only a larger number of identical newest-version requests
Answer: The supported client/server version combinations and relevant data states
A compatibility promise concerns the combinations actually allowed in service. Test those combinations, including meaningful stored and transitional states, rather than one ideal pair.
83.A confirmation dialog displays record A, but its submit handler reads a mutable global selection that has changed to B. What should the confirmed action bind to?
Show answer and explanation
- The intended target and relevant context shown for confirmation
- The most recently opened record in any tab
- A rule that identical dialog text makes the targets interchangeable
- Whichever record is selected when the network responds
Answer: The intended target and relevant context shown for confirmation
A confirmation must refer to the operation the user reviewed. Preserve target and context identity, and revalidate relevant state rather than silently redirecting consent to another resource.
84.A bulk permission change promises all-or-nothing behavior. One target is unauthorized, but earlier targets are already changed when the server rejects the batch. What is violated?
Show answer and explanation
- A requirement that every target have the same identifier
- The batch's atomic effect contract
- Only the order of error messages
- The assumption that an HTTP error undoes earlier writes automatically
Answer: The batch's atomic effect contract
A rejection response does not itself roll back effects. Use a design that actually preserves the promised atomicity and authorization checks across the whole operation.
85.An ETag describes only a public projection that omits an approval lock. A handler treats its match as proof that the lock has not changed. What should approval handling do?
Show answer and explanation
- Infer the lock from the browser's enabled button.
- Skip the lock check whenever the public fields are unchanged.
- Treat the public projection tag as a complete lock revision.
- Check the current lock using an appropriate business-state invariant.
Answer: Check the current lock using an appropriate business-state invariant.
A validator's meaning depends on what it represents. Enforce the relevant lock or version invariant separately, or use a suitable revision whose coverage matches the protected operation.
86.A denial test asserts HTTP 403, but the handler updates the record before returning that status. What should the test also establish?
Show answer and explanation
- A rule that error status codes prove transaction rollback
- Only the denial message's wording
- That no forbidden effect occurred
- The number of frontend buttons hidden for the test user
Answer: That no forbidden effect occurred
Authorization correctness includes effects, not only response labels. Inspect the protected state or other relevant effects to prove a denied operation did not execute.
87.A stated policy combines grants but lets any applicable explicit deny override them. One role grants export and another explicitly denies export. What is the result?
Show answer and explanation
- Choose whichever role was serialized first
- Allow export because at least one grant exists
- Deny export
- Allow export if the client omits the denying role from its display
Answer: Deny export
The supplied precedence rule makes an applicable deny decisive. Do not replace that policy with a grant count, client presentation rule, or serialization-order accident.
88.A search builder combines authorizationScope OR userFilter. A caller chooses a broad filter and receives out-of-scope records. What composition preserves the boundary?
Show answer and explanation
- Authorization scope AND the permitted user filter
- The caller filter alone whenever it parses
- The two predicates joined by OR
- A rule that a documented filter can widen the caller's authority
Answer: Authorization scope AND the permitted user filter
A user-controlled filter should narrow the authorized dataset, not provide an alternate route around its scope. Keep the mandatory authorization constraint outside the caller's control.
89.A server stores the current actor in one global variable. Two asynchronous requests overwrite it while awaiting data. What context model is needed?
Show answer and explanation
- A guarantee that single-threaded execution prevents interleaving across awaits
- A longer delay before authorization
- Request-isolated trusted actor context
- The actor from whichever request started last
Answer: Request-isolated trusted actor context
Asynchronous requests can interleave even on one thread. Pass or safely scope request context so an operation cannot inherit another request's identity.
90.An editor's old tab sends an update to a record that has since been soft-deleted. The handler checks edit rights but unintentionally restores the record. What else must be enforced?
Show answer and explanation
- Only whether the editor was once an owner
- The allowed operation for the record's current lifecycle state
- The assumption that authorization makes all business transitions valid
- A rule that every valid edit request may resurrect deleted records
Answer: The allowed operation for the record's current lifecycle state
Authorization is necessary but may not be sufficient. Enforce current lifecycle and transition rules; restoration should be an explicit authorized operation if the product supports it.
91.A settings API defines timeoutMs as milliseconds. A UI setting of two minutes must be serialized into that field. What value matches the contract?
Show answer and explanation
- 120000
- 2
- 2000
- 120
Answer: 120000
Two minutes is 2×60 seconds, and each second is 1,000 milliseconds: 2×60×1,000=120,000. Unit conversion belongs to the contract, not the display label alone.
92.A new renderer interprets existing user notes as HTML, although they were accepted and stored as plain text. What trust review is needed?
Show answer and explanation
- A rule that changing only the renderer cannot affect security
- A guarantee that previously stored text is safe HTML
- The new output interpretation of previously untrusted stored data
- The assumption that database storage sanitizes markup automatically
Answer: The new output interpretation of previously untrusted stored data
Storage does not transform untrusted content into trusted markup. Evaluate and implement safe handling for the new rendering context rather than inherit an old plain-text assumption.
93.A service promises that removing a role will erase every independent copy of a report users already downloaded. What limitation must the contract acknowledge?
Show answer and explanation
- Changing an ACL automatically changes all previously exported bytes.
- A shorter session lifetime deletes files on every client device.
- Server-side revocation cannot by itself recall independently retained copies.
- Hiding the download control erases existing local files.
Answer: Server-side revocation cannot by itself recall independently retained copies.
A service can control future access through its own enforcement points. It cannot claim to remove every independent copy merely by changing server permissions; distinguish access revocation from recall guarantees.
94.The ordered source is [hidden1, visible2, hidden3, visible4, visible5]. The page contract returns the first two visible records. Which result satisfies it?
Show answer and explanation
- [visible4, visible5]
- [visible2, visible4]
- [visible2]
- [hidden1, visible2]
Answer: [visible2, visible4]
Visibility filtering must be respected before applying the promised visible-page boundary, or through an equivalent safe process. Limiting the first two source rows and then filtering would underfill this page.
95.A gateway recognizes an HTTP field name only with one capitalization, while the backend accepts other capitalizations. What protocol rule should their parsing respect?
Show answer and explanation
- Field-name case changes the caller's authorization level.
- Only browser-generated field names are case-insensitive.
- HTTP field names are case-insensitive.
- Each intermediary may give the same field a different identity based on case.
Answer: HTTP field names are case-insensitive.
HTTP field names are case-insensitive. Apply consistent field handling and required checks rather than make a security boundary depend on a capitalization accident.
96.A save gets a version conflict. The client silently fetches the newest revision and resubmits the old form with its new validator, overwriting another edit. What protection was defeated?
Show answer and explanation
- The conflict-resolution step intended to prevent a lost update
- The requirement that JSON contain strings
- The assumption that all version conflicts require an automatic overwrite
- A rule that a newer validator proves the old changes were reconciled
Answer: The conflict-resolution step intended to prevent a lost update
Obtaining a fresh validator is not the same as reconciling changed content. Preserve the concurrency check's purpose and use an explicit suitable merge, retry, or user decision.
97.A bulk grant preview names three recipients. Before confirmation, group membership grows to ten, and execution silently targets the current group. What must the approval contract define?
Show answer and explanation
- The number of recipients displayed after completion only
- How the reviewed target set is bound or revalidated before effects
- A guarantee that approval of one snapshot authorizes all future members
- A rule that a group name proves membership never changes
Answer: How the reviewed target set is bound or revalidated before effects
A preview and an operation must agree about their targets and relevant state. Bind the reviewed set, reject stale confirmation, or explicitly define and communicate different dynamic semantics.
98.An audit event says 'grant committed' before the transaction completes; the transaction then rolls back. What should audit semantics distinguish?
Show answer and explanation
- The assumption that a service account cannot produce a failed transaction
- A rule that logging a success makes the change durable
- An authorized attempt from an actual committed effect
- A successful authorization decision treated as a commit
Answer: An authorized attempt from an actual committed effect
The audit trail should describe what actually happened. Record attempts and committed outcomes with suitable semantics and consistency, instead of labeling an uncommitted intention as a completed grant.
99.An authorization suite uses only an administrator acting on an owned active record. What would better test the boundary?
Show answer and explanation
- More repetitions of the same successful administrator request
- A matrix of relevant actors, actions, targets, relationships, and states
- A test that all menu items render for the administrator
- A rule assuming one privileged success proves tenant isolation
Answer: A matrix of relevant actors, actions, targets, relationships, and states
Positive cases exercise only part of a policy. Include meaningful denied and boundary cases across the dimensions that determine authorization, and verify appropriate effects as well as responses.
100.A permitted action is disputed after policy changes. Logs contain an actor and target but no decision-policy revision. What additional provenance can help explain the original decision?
Show answer and explanation
- The actor's raw credential copied into every log line
- A guarantee that today's policy exactly describes every earlier decision
- The most recent browser menu text as the historical policy
- The relevant policy version and decision context
Answer: The relevant policy version and decision context
Reconstructing a decision requires the relevant trusted context and policy semantics at the time. Preserve suitable provenance without treating logs as a place to expose credentials.
101.A REST controller enforces a permission rule, but a CSV import worker invokes the same protected operation without that rule. What should the architecture preserve?
Show answer and explanation
- The invariant across every authorized entry path to the domain operation
- The assumption that file-based input is trusted by default
- A rule protecting only the most common HTTP route
- A guarantee that internal workers cannot receive untrusted requests or data
Answer: The invariant across every authorized entry path to the domain operation
Protect the domain action consistently across supported entry paths. Controller checks alone are insufficient if alternate imports, workers, or other interfaces can bypass the same required rule.