open-telemetry / open-telemetry/opentelemetry-python-contrib
If URL has bad UTF-8 this will blow up and other error handling can't work around it.
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.1k
- Forks
- 1.1k
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 16
Description
Once request.url is referenced it tries to utf-8 decode. if there are bad continuation bytes this causes an error.
I would think pyramid should test this prior to any request being processed and probably should have a high level callback for bad requests that would result 400/401 type responses.
a/CPX_210929101749/0%DE~%C7%1FY
The above URL should trigger the issue with even a basic hello world app. Might have to change the path a bit.
I can't find any workaround in python. Might be able to use nginx/WAF etc to block prior to hitting the application. If these get through we just throw a 404, but the tween OTEL is using is too low level to workaround.
The fix would probably be to wrap in a try/except on reference to request.url. if you get an error you should handle like an excluded url.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in instrumentation/opentelemetry-instrumentation-pyramid/src/opentelemetry/instrumentation/pyramid/callbacks.py at line 165, where referencing request.url triggers the failure. Reproduce it with the malformed URL from the issue, then verify that bad UTF-8 is handled like an excluded URL rather than crashing request processing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- observability
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 56/100