vars: Don't expand placeholders in values#7629
vars: Don't expand placeholders in values#7629vnxme wants to merge 1 commit intocaddyserver:masterfrom
Conversation
|
Maybe I'm misunderstanding this proposed change, but it looks like I might be affected by it. # This snippet can be used to ensure that only the IP address used during JWT issuance
# is allowed to access the protected resource.
(snippet_check_current_ip_not_jwt_ip) {
# Check if client_ip matches the IP in the JWT
@client_ip_not_jwt_ip {
not vars {http.auth.user.ip} ""
not vars {client_ip} {http.auth.user.ip}
}
# Set this variable, so it can be handled by snippet_handle_errors_401
route @client_ip_not_jwt_ip {
vars jwt.client_ip_not_jwt_ip true
error 401
}
}If I understand the PR description correctly, values from placeholders and custom variables are now treated as final and are no longer expanded before matching. Wouldn't that mean that in a case like this, |
|
Directionally this looks right to me as a hardening update. The leak described in the PR seems real: today I do however think this needs two follow-ups before merge:
The docs for |
|
@steffenbusch, don't worry, you won't be affected, since it only deals with placeholders-in-placeholders and placeholders-in-vars scenarios -- you don't seem to have any of those, unless @steadytao, agree, it would be great to update the docs as well to match this code change. |
mholt
left a comment
There was a problem hiding this comment.
Thanks @vnxme -- really appreciate it!
Yeah I agree tests would be good to add. Maybe if someone has a chance they could contribute some tests? Could be a table-driven test with a few cases at least.
In the meantime I have tested these changes with a few things and it works well.
This PR prevents a potential leakage of sensitive information because of expanding placeholders in values of custom variables via
vars_regexp. For consistency, bothvarsandvars_regexpmatchers now treat values of placeholders and custom variables as final, i.e. don't expand them before matching.A config example of how it could have been exploited:
No AI has been involved.