testing-api-authentication-weaknesses

Tests API authentication mechanisms for weaknesses including broken token validation, missing authentication on endpoints, weak password policies, credential stuffing susceptibility, token leakage in URLs or logs, and session management flaws. The tester evaluates JWT implementation, API key handlin

By mukul975 · 421 installs

npx skills add mukul975/anthropic-cybersecurity-skills --skill testing-api-authentication-weaknesses

Source repository · Upstream listing

Testing API Authentication Weaknesses When to Use Assessing REST API authentication mechanisms for bypass vulnerabilities before production deployment Testing JWT token implementation for common weaknesses (none algorithm, key confusion, missing expiration) Evaluating whether all API endpoints enforce authentication or if some are unintentionally exposed Testing API key generation, storage, and rotation mechanisms for predictability or leakage Validating session management including token expiration, revocation, and refresh token security Do not use without written authorization. Authentication testing involves attempting to bypass security controls. Prerequisites Written authorization specifying target API and authentication mechanisms in scope Valid test credentials for at least two user roles (regular user, admin) Burp Suite Professional with JWT related extensions (JSON Web Tokens, JWT Editor) Python 3.10+ with requests , PyJWT , and jwt libraries Wordlists for credential testing (SecLists authentication wordlists) API documentation or OpenAPI specification Workflow Step 1: Authentication Mechanism Identification Step 2: Unauthenticated Endpoint Discovery Step 3: JWT Token Analysis Step 4: JWT Manipulation Attacks Step 5: Token Lifecycle Testing Step 6: Password Policy and Credential Testing Key Concepts Term Definition Broken Authentication OWASP API2:2023 weaknesses in authentication mechanisms that allow attackers to assume identities of legitimate users JWT (JSON Web Token) Self contained token format with header.payload.signature structure, used for stateless API authentication Token Revocation Server side mechanism to invalidate tokens before their expiration, critical for logout and password change Credential Stuffing Automated attack using leaked username/password pairs against authentication endpoints Account Enumeration Determining valid usernames through different error messages or response times for valid vs invalid accounts Refresh Token Rotation Security practice where each use of a refresh token generates a new one, preventing token reuse attacks Tools & Systems Burp Suite JWT Editor : Extension for decoding, editing, and re signing JWT tokens with various attack modes jwt tool : Python tool for JWT testing with 12+ attack modes including alg:none, key confusion, and JWKS spoofing hashcat : GPU accelerated password cracker supporting JWT HMAC secret brute forcing (mode 16500) Hydra : Network login brute forcer supporting HTTP form based and API authentication testing Nuclei : Template based scanner with authentication bypass detection templates Common Scenarios Scenario: SaaS Platform API Authentication Assessment Context : A SaaS platform uses JWT tokens for API authentication. The JWT is issued upon login and used for all subsequent API calls. A refresh token mechanism is also implemented. Approach : 1. Authenticate and capture the JWT: algorithm is HS256, expiration is 7 days, payload contains user role 2. Test alg:none bypass: server rejects the token (secure) 3. Brute force the HMAC secret: discover the secret is "company jwt secret 2023" (found using hashcat with custom wordlist) 4. Forge a JWT with admin role using the discovered secret: gain admin access to all endpoints 5. Test token revocation: tokens remain valid after logout and password change (no blacklist) 6. Test refresh token: refresh token has no expiration and can be reused indefinitely 7. Find that the password reset endpoint returns different messages for valid vs invalid emails 8. Discover that the /health and /metrics endpoints are accessible without authentication Pitfalls : Only testing the login endpoint and missing authentication weaknesses in password reset, MFA, and token refresh flows Not checking if the JWT secret is the same across all environments (dev, staging, production) Ignoring the token lifetime: a 7 day JWT with no revocation means a stolen token is valid for a week Not testing for token leakage in server logs, URL parameters, or error messages Output Format