Interview Prep/DevSecOps/Vulnerability Management and OWASP

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 →

  1. Revert the escalated accounts and check logs for role or is_admin in update payloads.
  2. 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"}
    
  3. Move role changes to a separate admin-only endpoint with its own authorization check.
  4. 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.

All DevSecOps questions Roadmap: Security in the pipeline

More on Vulnerability Management and OWASP