Questions may have code examples in multiple languages. Which one would you prefer?
JavaScript Python Java C#
Topic [1/3]: Applied Secure Error Handling and Fail-Secure Design
You're reviewing error handling and authorization failure behavior for a multi-tenant SaaS API.
The developer states that the design is secure because exceptions are handled centrally, stack traces are hidden in production, and fallback behavior keeps the service available when dependencies fail.
Continue
Considerations:
• exceptions use shared middleware • stack traces are hidden in production • requests receive correlation IDs • read-only requests use fallback behavior during policy-service outages • technical errors are logged for support
You are acting as a senior reviewer responsible for deciding whether the error-handling and failure design is production-ready.
Continue
Open the example as text in a separate window ↗
async def can_read_invoice(request, invoice):
try:
decision = await policy_client.check({
"userId": request.state.user_id,
"action": "invoice:read",
"resourceId": invoice.id,
})
return decision.allowed
except Exception as error:
logger.warning("policy_check_failed", extra={
"userId": request.state.user_id,
"error": repr(error),
})
# keep read-only workflows available
return request.method == "GET"
Continue
[1/4] Explain the main security concerns, unsafe assumptions, and what changes are required before this error-handling design would be safe for production use.
Type your answer and send it as a message.
The design fails open: if the policy check errors, GET requests are allowed, assuming read-only requests are safe. It also risks exposing internal errors through responses and logs. Authorization failures should deny by default, client errors should be generic, and logs sanitized.
Analyzing your answer…
✓You identified both security boundaries clearly: what the client learns from errors, and what happens when authorization cannot be verified. Good production-focused fixes. One further idea is to shape external failures consistently, so they don't reveal internal state.
Continue