-
-
Notifications
You must be signed in to change notification settings - Fork 290
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: sanitize URL to prevent leaking user credentials in logs #6175
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,3 +18,12 @@ export function isValidHttpUrl(urlStr: string): boolean { | |
|
||
return url.protocol === "http:" || url.protocol === "https:"; | ||
} | ||
|
||
/** | ||
* Sanitize URL to prevent leaking user credentials in logs | ||
* | ||
* Note: `urlStr` must be a valid URL | ||
*/ | ||
export function toSafePrintableUrl(urlStr: string): string { | ||
return new URL(urlStr).origin; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will strip out There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is desired in case someone provides secrets in query params. I don't know of anybody that does this but we can't prevent users from doing that and passing credentials directly as part of the URL is common because it works with all clients. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Got it, somehow I assumed credentials could be passed via URL username/password properties There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note that calling There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch! Completely forgot about that, I added a note to the function now and moved all URL logs after they are already validated by http / jsonrpc client. Also looked into sanitizing invalid URLs (in catch block) but that got too messy. |
||
} |
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.
Builder is a bit of an outlier right now, we allow to set multiple URLs via
--builder.urls
but only use the first URL (opts.urls[0]
). I opted to only log the URL which is actually used.@g11tech Is it intentional that we don't allow a fallback for the builder? I guess mev-boost is already doing the multiplexing and builder flow is stateful which makes fallback logic a bit problematic.
Maybe we want to reflect that in the CLI as well as currently it looks like it supports multiple urls