T05 · Unauthorized Access and Privilege Escalation
- Location
scripts/search_person.py:20- Finding
Caller-Controlled Viewer Identity Used for Access Control
- Content
View full analysis
Vulnerability Details
File Location:
scripts/search_person.py:20-27andSKILL.md:18-25
Vulnerability Type: Authentication and authorization bypass
Risk Level: HighVulnerable Code
scripts/search_person.py:20-27:python viewer_id = None # Parse optional --viewer_id if len(sys.argv) > 3 and sys.argv[2] == "--viewer_id": viewer_id = sys.argv[3] db = DBManager() results = db.search_person(query, viewer_id=viewer_id)SKILL.md:18-25:markdown - **User Privacy**: For private entries (e.g., family members), ensure you pass the correct `viewer_id` (e.g., `1234567890` for the specific authorized user). ## Workflows ### 1. Searching for a Person When a user asks about a specific historical figure or family member: - Run the python search script passing the name and the user's ID for privacy. - Example: `python3 scripts/search_person.py "康熙" --viewer_id "5104087055"`Technical Analysis
The script accepts
viewer_iddirectly from a command-line argument and passes it to the database privacy layer. It performs no authentication, signature verification, session binding, or other check proving that the caller owns the supplied identity.The documentation indicates that
viewer_idis used to access private family entries and provides a concrete ID-shaped value in an example. IfDBManager.search_persontreats equality between this supplied value and a record'screator_idas sufficient authorization, knowledge or guessing of another user's ID is enough to impersonate that user.Authorization identifiers must be derived from a trusted, authenticated execution context. A caller-supplied identifier is a claim, not proof of identity.
Attack Path
- An attacker learns or guesses the Telegram ID associated with a private record. Such identifiers may be disclosed through logs, examples, database results, or other interactions.
- The attacker invokes ...[truncated 1057 chars]
- Remediation
View remediation
Remediation Suggestions
- Remove unrestricted
--viewer_idinput from security-sensitive production workflows. - Derive the viewer identity from an authenticated Telegram update, signed token, or trusted service session.
- Pass an authenticated principal object to the database layer rather than a bare user-controlled string.
- Enforce authorization again inside
DBManager.search_person, including deny-by-default handling when no verified identity is present. - If command-line operation is necessary, require a short-lived signed credential and verify its issuer, audience, expiration, and binding to the requested viewer ID.
- Avoid displaying real or production-like user identifiers in documentation.
- Add tests confirming that a caller cannot obtain another creator's private records by supplying that creator's ID.
- Log denied access attempts without recording sensitive query results or authentication credentials.
- Remove unrestricted
