-
-
Notifications
You must be signed in to change notification settings - Fork 6
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
Usage of PHP SensitiveParameter for the URI password component #140
Comments
After some thoughts ... we could Remove the Solution B seems to be favored by Guzzle and is less intrusive than correctly implementing the However using the
|
The possible API would be:
An alternative would be to have only one method:
which would automatically redact the password from user info AND redact the value from the query string when the name is provided. In both cases the value will be masked using 5 for instance you would end up with: echo BaseUri::from('https://toto:tata@example.com/?token=abcd1234&user_id=5678')
->redactUserInfo()
->redactQueryPair('token')
->getUriString();
or
echo BaseUri::from('https://toto:tata@example.com/?token=abcd1234&user_id=5678')
->redacSensitiveParameter('token')
->getUriString();
// display https://toto:*****@example.com/?token=*****&user_id=5678 Of note: The changes (new API) would land on the The |
Hi @nyamsprod, sorry I totally forgot to answer here, read it originally on my phone and wasn't keen on writing a longer text there.
String parameters are truncated in stack traces anyway if there're too long, no? If so, the expectation of seeing the full URI isn't one that happens in practise. User info is indeed deprecated for good reason, because it's easy to leak the secret authentication data as can be seen in this issue. However, there's also another case to consider: What about capability URLs? The "Risk of Exposure" summarizes very well that keeping the really secret is challenging. I think adding it to more rather than less places doesn't really hurt, but I'd focus on methods that pass passwords (including parse). I wouldn't build redaction into |
Maybe we can have something that ressemble the UriRedactor::__construct(string $mask = '****', string ...$defaultRedactedNames);
UriRedactor::redact(Stringable|string $uri, string ...$names): string
Of note, the redact returns a string and not an object because as I stated the returned value And we leave the |
Sounds good! Elastic has a list we can probably start with: https://www.elastic.co/guide/en/apm/agent/java/current/config-core.html#config-sanitize-field-names |
I reverted the added usage of SensitiveParameter as discussed. |
Question
The
#[SensitiveParameter]
PHP attribute was added to the$password
property from URI. The problem is that it was only added on the class constructor and public user info modifier method. On master I have pushed a commit that improve the situation by applying the attribute everywhere the password component could be passed. This result in, for instance, having the attribute added to theUriString::parse
.On one hand this is consistent as we are hidden potential credential information but on the other hand this increase complexity for whoever expects to see the full URI when an error occurs. Also the use of password in URI is deprecated by RFC3986 so is the tradeoff worthwhile ?
@kelunik what do you think we should do ?
Thanks in advance for the commet/suggestion
The text was updated successfully, but these errors were encountered: