Compare gateway traffic with direct service access and authenticate forwarded identity without confusing headers with evidence.
Intermediate45 min·updated 2026-11-15
You’re reading a preview. Premium includes the full lesson and specialist practice. View the full curriculum.
A role check can be correct over a forged principal
Distributed APIs often verify user credentials at a gateway and forward identity to downstream services. This can be a sound architecture when the downstream service authenticates the forwarding authority, constrains ingress, and preserves the asserted audience and delegation. A header alone does not establish those guarantees.
RefundDesk's gateway validates the user token and replaces inbound X-User-Id and X-User-Role headers. The refund service checks that the resulting role is refund-admin and atomically queues the stored refundable amount. However, VPN clients can reach the service directly and choose those headers themselves.
The first failed guarantee is principal provenance: who supplied the identity context? The role comparison can work perfectly while checking an attacker-selected role.
Continue with Premium
Continue API Security with the complete lessons, guided exercises, code-review challenges and assessments.