Skip to content

Security: nikhil-maryala/bearer-token-extractor

Security

SECURITY.md

Security Review & Analysis

Overview

This document provides a comprehensive security analysis of the Bearer Token Extractor Chrome extension, including identified risks, security measures, and recommendations for safe usage.

Security Analysis

πŸ” What This Extension Does

  1. Intercepts HTTP Requests: Monitors all HTTP/HTTPS requests made by web pages
  2. Extracts Authorization Headers: Captures bearer tokens from Authorization headers
  3. Decodes JWT Tokens: Parses JWT tokens to extract payload information
  4. Stores Tokens in Memory: Keeps captured tokens in the extension's memory (per tab)
  5. Displays Token Information: Shows tokens, URLs, and types in the popup interface

⚠️ Security Risks & Considerations

HIGH RISK: Token Exposure

  • Risk: The extension captures and stores authentication tokens that grant access to user accounts
  • Impact: If the extension is compromised or tokens are mishandled, unauthorized access to user accounts is possible
  • Mitigation:
    • Tokens are stored only in memory (not persisted to disk)
    • Tokens are isolated per browser tab
    • Tokens are automatically cleared when tabs are closed

HIGH RISK: Broad Permissions

  • Risk: Extension has access to ALL websites (<all_urls>)
  • Impact: Can intercept traffic from any website the user visits
  • Mitigation:
    • Extension only reads Authorization headers, not full request/response bodies
    • No data is sent to external servers
    • All processing happens locally

MEDIUM RISK: JWT Decoding

  • Risk: Extension decodes JWT tokens to extract payload information
  • Impact: Payload may contain sensitive user information (email, roles, etc.)
  • Mitigation:
    • Decoded payloads are stored only in memory
    • No logging or external transmission of decoded data

MEDIUM RISK: Tab Navigation Control

  • Risk: Extension can navigate tabs to arbitrary URLs
  • Impact: Could be exploited to redirect users to malicious sites if compromised
  • Mitigation:
    • Navigation only triggered by explicit user action (button clicks)
    • No automatic navigation without user consent

LOW RISK: Clipboard Access

  • Risk: Extension copies tokens to clipboard when user clicks "Copy"
  • Impact: Clipboard contents may be read by other applications
  • Mitigation:
    • Clipboard access only on explicit user action
    • Users should be aware of clipboard contents

βœ… Security Features

  1. Memory-Only Storage

    • Tokens are NEVER written to disk or localStorage
    • All data cleared when browser/extension is closed
    • Per-tab isolation prevents cross-tab token leakage
  2. No External Communication

    • Extension does NOT send data to any external servers
    • No analytics, telemetry, or tracking
    • All processing is 100% local
  3. Minimal Data Collection

    • Only captures Authorization headers
    • Does not access cookies, form data, or response bodies
    • Does not monitor user input or browsing behavior
  4. Tab Isolation

    • Tokens captured in one tab are isolated from other tabs
    • Automatic cleanup when tabs are closed
  5. No Code Injection

    • Extension does not inject scripts into web pages
    • Uses only Chrome extension APIs for monitoring

🚨 Identified Vulnerabilities

1. No Input Validation on URLs

  • Issue: User-provided URLs in the navigation input are not validated
  • Risk: Users could be tricked into navigating to malicious URLs
  • Severity: LOW (requires user action)
  • Recommendation: Add URL validation to prevent javascript: or data: URLs

2. JWT Decoding Error Handling

  • Issue: JWT decoding failures are silently caught
  • Risk: Malformed tokens could cause unexpected behavior
  • Severity: LOW (gracefully handled with try-catch)
  • Status: Acceptable (returns null on failure)

3. Message Handler Vulnerabilities

  • Issue: Message handlers don't validate sender origin
  • Risk: Other extensions could potentially send messages
  • Severity: LOW (messages only control navigation and data retrieval)
  • Recommendation: Add sender validation in message listeners

4. No Content Security Policy

  • Issue: No CSP defined in manifest.json
  • Risk: If popup HTML is compromised, inline scripts could execute
  • Severity: LOW (popup is fully controlled by extension)
  • Recommendation: Add CSP to manifest for defense in depth

Permissions Breakdown

Required Permissions

1. webRequest

  • Purpose: Intercept HTTP requests to extract Authorization headers
  • Access Level: Read-only access to request headers
  • Risks: Can see URLs and headers of all requests
  • Justification: Core functionality - required to capture bearer tokens

2. activeTab

  • Purpose: Access the currently active tab to retrieve tab ID and manage tokens
  • Access Level: Limited access to current tab only
  • Risks: Can read current tab URL and basic metadata
  • Justification: Required to isolate tokens per tab

3. scripting

  • Purpose: Listed but NOT currently used in the code
  • Access Level: Would allow script injection into pages
  • Risks: Could inject arbitrary JavaScript into web pages
  • Justification: NOT NEEDED - Should be removed from manifest

4. host_permissions: <all_urls>

  • Purpose: Monitor requests from all websites
  • Access Level: Access to all HTTP/HTTPS requests
  • Risks: Can intercept traffic from any website
  • Justification: Required for development/testing tools; users should limit to specific domains in production

Recommended Permission Changes

Remove scripting permission - Not used in current implementation

"permissions": [
  "webRequest",
  "activeTab"
]

Optional: Restrict host_permissions - For production use, limit to specific domains

"host_permissions": [
  "https://*.uipath.com/*"
]

Security Best Practices for Users

βœ… DO:

  • Only install this extension from trusted sources
  • Use only on websites you own or have permission to test
  • Clear tokens frequently using the "Clear All" button
  • Unload/disable the extension when not actively using it
  • Review what tokens are captured before copying them
  • Use in development/testing environments only

❌ DON'T:

  • Share captured tokens with unauthorized parties
  • Leave the extension enabled on production systems
  • Use on shared computers without clearing tokens afterward
  • Install modified versions from unknown sources
  • Grant access to untrusted websites
  • Use for malicious purposes or unauthorized access

Compliance Considerations

Privacy

  • βœ… No data collection or external transmission
  • βœ… No persistent storage of sensitive data
  • βœ… No tracking or analytics
  • ⚠️ Captures authentication credentials (by design)

Security Standards

  • βœ… Follows Manifest V3 security requirements
  • βœ… Uses service workers (no persistent background pages)
  • ⚠️ Broad permissions (necessary for functionality)
  • ❌ No code signing (unpacked extension)

Recommended for:

  • βœ… Development and testing environments
  • βœ… Security research and penetration testing
  • βœ… Debugging authentication issues
  • ❌ Production environments
  • ❌ Shared/public computers
  • ❌ Unauthorized testing

Incident Response

If Extension is Compromised:

  1. Immediately disable the extension in chrome://extensions/
  2. Clear browser cache and data for affected websites
  3. Revoke/rotate any captured tokens through the respective services
  4. Change passwords for affected accounts
  5. Review browser extension permissions and remove suspicious extensions

If Tokens are Leaked:

  1. Immediately revoke the tokens in the identity provider
  2. Force logout all active sessions
  3. Change account passwords
  4. Enable 2FA/MFA if not already enabled
  5. Review audit logs for unauthorized access

Recommendations for Improvement

High Priority:

  1. Remove unused scripting permission from manifest.json
  2. Add URL validation to prevent navigation to dangerous protocols
  3. Implement sender validation in message handlers
  4. Add CSP headers to popup HTML

Medium Priority:

  1. Add token expiration checking - warn users about expired tokens
  2. Implement auto-clear timer - option to clear tokens after N minutes
  3. Add export/import blocklist - prevent capturing tokens from specific URLs
  4. Scope host_permissions - allow users to limit to specific domains

Low Priority:

  1. Add token masking option - show only first/last characters
  2. Implement audit log - track when tokens were captured/copied
  3. Add warning banner - remind users about security implications

Conclusion

This extension is a powerful development tool that handles sensitive authentication credentials. While it includes reasonable security measures for its intended use case, users must understand the risks:

  • Intended Use: Development, testing, and debugging authentication flows
  • Security Posture: Acceptable for controlled environments, NOT for production
  • Risk Level: HIGH if misused or compromised
  • Recommendation: Use with caution, follow security best practices, and limit permissions where possible

Contact

For security concerns or to report vulnerabilities, please create an issue in the GitHub repository.

Last Updated: 2025-12-26

There aren't any published security advisories