Spot the bug
Which line lets a user make themselves an admin?
from dataclasses import dataclass@dataclassclass User:name: stremail: stris_admin: bool = Falsedef update_profile(user: User, body: dict[str, str | bool]) -> User:for key, value in body.items():setattr(user, key, value)return user
Hint 1 of 1
Which keys can the client send?
Choose an answer, then open Show answer below to check it.
Show answer
- Answer: line 13
setattr(user, key, value)
Line 13 copies every key from the body, including is_admin. Copy only allow-listed fields like name and email.