Token-Based Authentication

Security implications & exposure vectors

Token-based authentication (passing tokens in URLs like https://app.com/board/SECRET_TOKEN) offers simplicity but introduces multiple security exposure points. This approach prioritizes usability over security—understanding the tradeoffs is critical.

Where Tokens Get Logged

Every component in the request chain sees and potentially logs the full URL, including your token:

Web Server Logs

Apache access.log, Nginx logs, IIS logs—all record complete URLs by default.

Reverse Proxies

Cloudflare, nginx proxy layers, load balancers all see and log request URLs.

CDN Providers

If serving through a CDN (Cloudflare, Fastly, AWS CloudFront), tokens are visible in their logs.

Browser History

Tokens persist in browser history permanently—survives restarts, sync to cloud.

Analytics Platforms

Google Analytics, Plausible, Matomo collect full URLs unless explicitly filtered.

Bookmarks & Shares

Users accidentally share tokens when bookmarking or copy-pasting links.

CRITICAL: Referer Header Leakage

When a user clicks an external link from your app, the browser sends the full URL (including token) in the Referer header:

GET /some-page HTTP/1.1
Host: external-site.com
Referer: https://yourapp.com/board/SECRET_TOKEN_HERE

The external site now has your user's token. This is the most dangerous exposure vector for URL-based tokens.

Blocking Referer Leakage

The Referrer-Policy header controls what information the browser includes in the Referer header. This is your primary defense against token leakage.

Implementation Methods

1. HTTP Header (Recommended - Global)

Set at the server level to apply across all pages:

server {
    add_header Referrer-Policy "no-referrer" always;
}
# .htaccess or VirtualHost
Header set Referrer-Policy "no-referrer"

2. HTML Meta Tag

Add to <head> section of every page:

<meta name="referrer" content="no-referrer">

3. Per-Link Attribute

Apply to specific external links:

<a href="https://external.com" referrerpolicy="no-referrer">
    External Link
</a>
Policy Options (Strictest → Most Permissive)
  • no-referrer — Never send referrer (most secure for tokens)
  • same-origin — Only send for same-domain links
  • origin — Send only domain, strip path (e.g., https://app.com)
  • strict-origin-when-cross-origin — Modern balanced default
  • no-referrer-when-downgrade — Browser default (HTTPS→HTTPS only)
FOR TOKEN-IN-URL APPS: Use no-referrer or same-origin to prevent token leakage to external sites. This is mandatory, not optional.

Additional Mitigations

Long, Random Tokens

Minimum 32 bytes (64 hex characters) from cryptographically secure random source. Makes brute-force attacks infeasible.

Token Rotation

Allow users to regenerate tokens with one click. Invalids old token immediately.

Tradeoff: User can lose access if they don't save the new token. Provide clear UI and confirmation.

Rate Limiting

Limit requests per token per IP/time window. Prevents brute-force and limits damage from leaked tokens.

Suspicious Activity Alerts

Notify users of access from new IP addresses, countries, or unusual patterns. Consider blocking + requiring re-auth.

HTTPS Only

Enforce HTTPS everywhere. HTTP transmits tokens in plaintext over the network.

Alternatives to URL Tokens

If security is a higher priority than simplicity:

Bearer Tokens

Pass in Authorization header. Not logged by default, not in browser history.

HttpOnly Cookies

JavaScript cannot access, more resistant to XSS. Automatic with requests.

Session-Based Auth

Server-side session storage. Most secure but requires login flow + backend state.

Risk Assessment

Is URL-based token auth acceptable for your use case?

HIGH RISK — Avoid URL tokens
  • Healthcare data (HIPAA/GDPR protected)
  • Financial information
  • Personally identifiable information (PII)
  • Corporate/confidential documents
MEDIUM RISK — Acceptable with mitigations
  • Family calendars & shared planning
  • Personal productivity tools
  • Collaborative documents (non-confidential)
  • Requirement: Implement all mitigations above
LOW RISK — URL tokens fine
  • Single-user tools (like productive.quest)
  • Public/semi-public data
  • Read-only access to non-sensitive content