T05 · Unauthorized Access and Privilege Escalation
Error
- Location
- SKILL.md:340
- Finding
- Client-Controlled User Identity Permits Unauthorized Premium Operations<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md`, lines 340–355 **Vulnerability Type**: Broken object-level authorization **Risk Level**: High ### Vulnerable Code ```go func (s *Server) PremiumGetStatus(ctx context.Context, req *mtproto.TLPremiumGetStatus) (*mtproto.PremiumStatus, error) { status, err := s.premiumCore.GetPremiumStatus(ctx, req.UserId) if err != nil { return nil, err } return &mtproto.TLPremiumStatus{ UserId: status.UserID, Status: status.Status, ExpiresAt: status.ExpiresAt, }, nil } func (s *Server) PremiumPurchase(ctx context.Context, req *mtproto.TLPremiumPurchase) (*mtproto.Bool, error) { err := s.premiumCore.PurchasePremium(ctx, req.UserId, int(req.PlanId), req.PaymentMethod) if err != nil { return mtproto.BoolFalse, err } return mtproto.BoolTrue, nil } ``` ### Technical Analysis The RPC handlers use `req.UserId` directly as the identity on which the operation is performed. The examples do not derive the acting user from authenticated context or verify that the caller is authorized to operate on the supplied user ID. Input validation that only checks whether a user ID is syntactically valid would not prevent this vulnerability. The target resource must be bound to the authenticated principal, or access must be authorized through a separate privileged role. ### Attack Path 1. An attacker authenticates as user A. 2. The attacker obtains or guesses the identifier of user B. 3. The attacker sends `PremiumGetStatus` with user B's identifier. 4. The server queries and returns user B's premium information without an ownership check. 5. Alternatively, the attacker calls `PremiumPurchase` with user B's identifier. 6. The server initiates premium processing for user B because the request body is treated as authoritative identity information. ### Impact Assessment An authenticated user may be able to read another user's premium status or initia ...[truncated 249 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions - Derive the acting user ID from authenticated server-side context rather than the request body. - If the method only operates on the caller, remove `user_id` from the public request entirely. - If acting on another user is a legitimate administrative feature, require an explicit role and resource-level authorization check. - Reject requests where the supplied user ID differs from the authenticated identity unless delegated access is verified. - Add negative authorization tests showing that user A cannot query or modify user B. - Record authorization failures without logging sensitive request contents. ]]>
