-
-
Notifications
You must be signed in to change notification settings - Fork 58
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 tokens for the blacklist #352
Conversation
@@ -89,6 +89,7 @@ defmodule SupavisorWeb.Router do | |||
blocklist = Application.fetch_env!(:supavisor, blocklist_key) | |||
|
|||
with ["Bearer " <> token] <- get_req_header(conn, "authorization"), | |||
token <- Regex.replace(~r/\s|\n/, URI.decode(token), ""), |
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.
why not
blocklist =
Application.get_env(:realtime, blocklist_key, [])
|> Enum.map(&String.trim/1)
|> Enum.map(&String.downcase/1)
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 repeated the same approach as in JwtAuthToken to ensure we manipulate the same string
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.
supavisor/lib/supavisor/jwt.ex
Line 39 in d6897df
Regex.replace(~r/\s|\n/, URI.decode(token), "") |
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.
but why URI decode it? really curious about it.
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.
you can hide some symbols via HTML characters, which token sanitization can skip but the JWT library can decode
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.
TIL 👀 will copy pasta it into realtime 🍝
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.
should we do the same to the blocklist tokens?
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 guess not, because we can check that they are without spaces or new lines?
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.
wdyt?
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.
fair... fair...
No description provided.