-
Notifications
You must be signed in to change notification settings - Fork 838
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
instrumentation-http uses the wrong method to parse URLs for outgoing requests #5060
Comments
@gcampax, here’s a sample script that demonstrates how to use OpenTelemetry to instrument an HTTP request to a URL with non-ASCII characters:
Explanation:
Step 3: Run the ScriptYou can run this script using Node.js: bash Make sure to replace your-script-name.js with the actual name of your script file. This will execute the HTTP request to the URL with non-ASCII characters and log the response. |
Hi thanks for creating this reproducer, did you run it? Do you see the issue? |
No. try and run the code snippet in your editor and let me know your reply or rather share your code where you have this issues so I can pinpoint what you might be doing wrong. |
Your script is buggy, but this one works:
Run it like this and you get
Comment out all the OpenTelemetry init code / module loading and the request succeeds. As I mentioned in the original comment, there is a clear bug in the OpenTelemetry code, where the wrong URL parsing function is used (a bug that could have security implications, given the documentation for |
Thanks for the detailed report and the reproducer @gcampax - I'll try to find someone to work on this ASAP. |
What happened?
instrumentation-http intercepts all requests made with the http or https node modules, but if the first argument is a string, it uses
url.parse()
to convert the string url into the RequestOptions object, instead ofnew URL()
as documented by nodejs (in recent versions).This causes a discrepancy between instrumented and non-instrumented requests, in particular with regards to requests that have unescaped non-ASCII Unicode characters in the path or query
Steps to Reproduce
Have a script that makes a request to a URL containing a non-ASCII Unicode character (not percent encoded).
Expected Result
The request succeeds, as if the character was % encoded.
(This is what happens if the request is not instrumented)
Actual Result
TypeError: Request path contains unescaped characters
OpenTelemetry Setup Code
I'm not using OpenTelemetry directly. OpenTelemetry is setup by the Sentry node js SDK.
package.json
@opentelemetry/instrumentation-http
: 0.53.0Relevant log output
No response
The text was updated successfully, but these errors were encountered: