An API lets users update their profile with a JSON body, and a tester set `"role": "admin"` successfully. What went wrong?
BeginnerScenarioVulnerability Management and OWASP
Answer
Situation read → Mass assignment, listed in the OWASP API Top 10 as Broken Object Property Level Authorization. The handler bound the whole request body to the user model.
What I'd do →
- Revert the escalated accounts and check logs for
roleoris_adminin update payloads. - Use an explicit allowlist DTO for the endpoint:
class ProfileUpdate(BaseModel): display_name: str | None = None avatar_url: HttpUrl | None = None model_config = {"extra": "forbid"} - Move role changes to a separate admin-only endpoint with its own authorization check.
- Add an API test that sends forbidden fields and expects a 4xx.
Why → Binding whole objects is convenient and dangerous; allowlists make the attack surface explicit.
Interview tip → Reference the OWASP API Security Top 10 (2023), not only the web Top 10.
More on Vulnerability Management and OWASP
A pentest report shows SQL injection in a search endpoint of a Java service. How do you handle it end to end?BeginnerA scanner reports 4,000 open CVEs across 300 images. The team can fix maybe 100 a month. How do you prioritise?IntermediateA user reports they can see another customer's invoice by changing the ID in the URL. What do you do?BeginnerA webhook feature lets users enter a URL, and a pentester used it to read the cloud metadata endpoint. How do you fix it?AdvancedA team still runs Log4j 2.14 in an internal service and says it is not internet-facing. How do you respond?IntermediateA security review finds passwords stored as unsalted MD5 hashes. How do you migrate without forcing every user to reset?Advanced