The Real Fullstack

The Broken Authorization

Every request is authenticated. So how did Alice read Bob's order?

Engenheiro9 minLaboratório de depuraçãoDesafio de código
restspring-securityjavaoauth2

Este desafio ainda não foi traduzido para Português (Brasil). Você está lendo a versão em inglês.

Missão:Apply authorization checks so every legitimate request still works and none of the illegitimate ones does.Contexto · Objetivos de aprendizagem ▾

Brightcart's orders API checks that requests carry a valid token. A security researcher reported that changing /orders/A-17 to /orders/B-42 returns another customer's order, including address and payment details. Support agents serve several tenants.

Missão: Apply authorization checks so every legitimate request still works and none of the illegitimate ones does.

Objetivos de aprendizagem

  • Distinguish authentication from authorization.
  • Implement object-level and tenant-level checks.
  • Recognise security through obscurity.
SimulaçãoSimulado

Execute a simulação para ver a saída.

Executar simulação
@GetMapping("/orders/{id}")public OrderDto get(@PathVariable String id, Authentication auth) {  return orders.findById(id).map(OrderDto::of).orElseThrow();   // authenticated ≠ authorized}

Simplificação

Seven representative requests; each check is a declarative predicate. Modelo educacional — os números ilustram comportamento, não são benchmarks.

Conceitos

Desafios relacionados

Referências