-
Notifications
You must be signed in to change notification settings - Fork 111
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(compatibility): Replace or add RPC content type header when applicable #6885
Conversation
Before the change:
After:
Zcash-cli after the change:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've had a look at this PR, and it solves the compatibility problem in a really neat way.
But it also potentially introduces other security issues.
content-type headers exist so that applications know they are speaking the correct protocol with the correct format. We can be a bit flexible, but there are some types (such as binary) we shouldn't allow.
In particular, the "application/x-www-form-urlencoded" header should be rejected, so browser forms can't be used to attack a local RPC port. See "The Role of Routers in the CSRF Attack" in:
https://www.invicti.com/blog/web-security/importance-content-type-header-http-requests/
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #6885 +/- ##
==========================================
- Coverage 77.72% 77.46% -0.27%
==========================================
Files 310 310
Lines 41416 41523 +107
==========================================
- Hits 32192 32167 -25
- Misses 9224 9356 +132 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
The security comments are needed so we know why we only replaced the text/plain header. The code cleanup is optional.
I've labelled this PR so it doesn't merge yet, because we started a stable release freeze on Friday, and this isn't a release blocker.
Can you do these manual tests again when you've finished changing the code? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this is good to go as soon as we've re-done the manual tests. (And tagged the stable release.)
it seems we have a problem, the zcashd documentation use |
Good question! We could replace anything that starts with
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fix and the extra tests!
Motivation
We want Zebra to support the curl examples from the zcashd rpc documentation like https://zcash.github.io/rpc/getblockchaininfo.html where the content type header is
text/plain
.Close #6363
Solution
The solution here actually ignores any content type sent by the client and always use
application/json
which is the only type we support. I could be wrong here.Review
Anyone can review.
Reviewer Checklist