Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(instrumentation-http): skip malformed forwarded headers #5099

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

pmlanger
Copy link

Which problem is this PR solving?

Skips malformed forwarded headers instead of throwing an uncaught exception.

Fixes #5095

Short description of the changes

Introduce parseForwardedHeader in experimental/packages/opentelemetry-instrumentation-http/src/utils.ts which wraps forwarded-parse and returns an empty array on any caught exception.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

First, wrote a test that broke the instrumentation in the expected way (throwing ParseError: Unexpected end of input).
Then, fixed it and confirmed the test passes.

Checklist:

  • Followed the style guidelines of this project
  • Unit tests have been added
  • Documentation has been updated

Copy link

linux-foundation-easycla bot commented Oct 30, 2024

CLA Signed


The committers listed above are authorized under a signed CLA.

@omBratteng
Copy link

I think this would solve an issue we stumbled upon, where the forwarded header contains a base64 encoded value that ends with a =, and technically makes it malformed.

Could you add a test case for this value?

for=127.0.0.1;host=something.vercel.app;proto=https;sig=0QmVhcmVyIDc3MGNlY2M5YTIyZjJmNTg1ZGNlOTQ1NTUzMTIwMGFkMmZhOGEzZGNiM2M2NWQ4ZDk2ZGI5MDExMDkzMjkwYWM=;exp=1730556049

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.

opentelemetry-instrumentation-http throws on requests with malformed Forwarded headers
4 participants