Skip to content

security: don't leak Apify token if keep_headers and Authorization header is used - #30

Merged
metalwarrior665 merged 1 commit into
masterfrom
claude/security-report-explanation-c57h3a
Aug 19, 2026
Merged

security: don't leak Apify token if keep_headers and Authorization header is used#30
metalwarrior665 merged 1 commit into
masterfrom
claude/security-report-explanation-c57h3a

Conversation

@metalwarrior665

Copy link
Copy Markdown
Member

Summary

This PR adds security protection to prevent sensitive credential headers from being forwarded to target websites when the keep_headers option is enabled. This ensures that the caller's Apify API token and proxy credentials are never exposed to the scraped website's operator.

Key Changes

  • Added CREDENTIAL_HEADERS constant in src/const.ts that defines headers containing authentication credentials (authorization and proxy-authorization)
  • Updated createRequestForCrawler() in src/utils.ts to filter out credential headers before forwarding request headers to the target website
  • Updated README documentation to clarify that Authorization and Proxy-Authorization headers are never forwarded, protecting the user's Apify API token

Implementation Details

  • The credential header filtering is case-insensitive (using toLowerCase()) to handle various header casing conventions
  • The filtering occurs before other header validation logic, ensuring credentials are always protected regardless of other conditions
  • The implementation is minimal and focused, adding only the necessary security check without affecting other header forwarding behavior

https://claude.ai/code/session_01Lphs4iiGsBBumxe9uezJ9B

The keep_headers=true parameter copied every inbound header onto the
outbound request, including the Authorization header that callers use to
authenticate to this Actor. Any caller who authenticated with an
Authorization header and scraped a URL they did not control leaked their
Apify API token to that URL's operator. Because Apify tokens are
account-scoped, the impact reached well beyond this Actor.

README.md already documented that the Authorization header is stripped in
this mode; the implementation never did it. The sibling spb-/ant- prefixed
forwarding path in the same function does filter headers (cookie,
set-cookie, host), so the mechanism existed but was not applied here.

Strip authorization and proxy-authorization in the keep_headers path, and
update the README to state the guarantee it now actually keeps. Headers
explicitly opted in per-request via the spb-/ant- prefixes are unchanged:
those carry a value the caller chose to send to the target.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Lphs4iiGsBBumxe9uezJ9B
@metalwarrior665 metalwarrior665 changed the title Prevent credential headers from being forwarded to target websites security: don't leak Apify token if keep_headers and Authorization header is used Aug 19, 2026
@metalwarrior665
metalwarrior665 merged commit bd0290b into master Aug 19, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants