Skip to content
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

Oauth2 client: Allow deescalating logged ERROR for invalid client registration ID #11344

Closed
PunchyRascal opened this issue Jun 7, 2022 · 9 comments
Assignees
Labels
in: oauth2 An issue in OAuth2 modules (oauth2-core, oauth2-client, oauth2-resource-server, oauth2-jose) type: enhancement A general enhancement
Milestone

Comments

@PunchyRascal
Copy link

Current Behavior

Currently, when attempting to work withz invalid client ID, an ERROR is logged : Authorization Request failed: java.lang.IllegalArgumentException: Invalid Client Registration with Id: xxxl

(org.springframework.security.oauth2.client.web.DefaultOAuth2AuthorizationRequestResolver#resolve(javax.servlet.http.HttpServletRequest, java.lang.String, java.lang.String))

Desired Behavior

Avoid ERRORs in logs for this case (either setup or altogether - switch to warning maybe?)

Context

When a security/penetration scan is run on the app, many errors like this are logged, but do not represent any actual problem with the app. All the errors are just a result of the scan. Therefore it would be nice if this error could be silenced - maybe changed to warning.

Thank you.

@PunchyRascal PunchyRascal added status: waiting-for-triage An issue we've not yet triaged type: enhancement A general enhancement labels Jun 7, 2022
@jgrandja
Copy link
Contributor

@PunchyRascal There is only one log statement in OAuth2AuthorizationRequestRedirectFilter. Have you considered trying to turn off logging during penetration tests? For example:

logging.level.org.springframework.security.oauth2.client.web.OAuth2AuthorizationRequestRedirectFilter=OFF

@jgrandja jgrandja added status: waiting-for-feedback We need additional information before we can continue and removed status: waiting-for-triage An issue we've not yet triaged labels Jun 15, 2022
@PunchyRascal
Copy link
Author

Since the pentest is a regular occurrence, I think that would not be sustainable - to keep turning this off and on again and releasing to prod.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Jun 15, 2022
@jgrandja
Copy link
Contributor

@PunchyRascal A correctly configured application would not send an invalid client registration id. I understand your pentest is a different testing scenario but it doesn't make sense to "convenience" a pentest scenario as this would also "convenience" a malicious request that was attempting to guess a valid registration id. I would prefer to be disruptive to a malicious request by keeping this existing behaviour and throwing an exception. Makes sense?

@jgrandja jgrandja added status: waiting-for-feedback We need additional information before we can continue in: oauth2 An issue in OAuth2 modules (oauth2-core, oauth2-client, oauth2-resource-server, oauth2-jose) and removed status: feedback-provided Feedback has been provided labels Jul 18, 2022
@PunchyRascal
Copy link
Author

PunchyRascal commented Jul 18, 2022

I could argue that protection against brute force attacks is not in the scope of this module, if that is what you're saying, but hey - who am I? If you do not think this is doable, even via settings, we'll have to manage otherwise 🙂

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Jul 18, 2022
@jgrandja
Copy link
Contributor

@PunchyRascal

I could argue that protection against brute force attacks is not in the scope of this module, if that is what you're saying

No that's not what I'm saying. As mentioned in previous comment

A correctly configured application would not send an invalid client registration id

An invalid client registration id in the request is an error in the calling application, hence, the signal of the error condition to the caller so they can correct.

@PunchyRascal
Copy link
Author

This request is about log messages being generated. I am working under the assumption, that the caller does not have access to the Oauth app's logs.

@jgrandja
Copy link
Contributor

Apologies @PunchyRascal, it looks like I misinterpreted the request. If it's as simple as changing the log message from error to warn for invalid client registration id scenarios then we can apply the enhancement. Please confirm if this is exactly what you're looking for.

@PunchyRascal
Copy link
Author

Yes, that would be great.

@jgrandja jgrandja assigned sjohnr and unassigned jgrandja Sep 1, 2022
@jgrandja jgrandja removed the status: feedback-provided Feedback has been provided label Sep 1, 2022
@sjohnr
Copy link
Member

sjohnr commented Sep 1, 2022

Awesome, thanks @PunchyRascal!

I do want to point out for future users encountering this issue that this change (logging invalid client registration ID at WARN level) will still require many applications to tune their logs to get rid of this warning. However, it will allow this message to be turned off permanently if desired while still retaining other errors in the logs.

@sjohnr sjohnr added this to the 5.8.x milestone Sep 19, 2022
sjohnr added a commit to sjohnr/spring-security that referenced this issue Sep 19, 2022
This prevents filling the log file with error messages when routine
scans are being performed.

Closes spring-projectsgh-11344
@sjohnr sjohnr closed this as completed in bbac85e Sep 26, 2022
@sjohnr sjohnr moved this to Done in Spring Security Team Sep 26, 2022
@sjohnr sjohnr modified the milestones: 5.8.x, 5.8.0-RC1 Sep 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: oauth2 An issue in OAuth2 modules (oauth2-core, oauth2-client, oauth2-resource-server, oauth2-jose) type: enhancement A general enhancement
Projects
Archived in project
Development

No branches or pull requests

4 participants