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

Fix race condition during ACME authz polling #4561

Merged
merged 1 commit into from
Sep 14, 2023

Conversation

edewata
Copy link
Contributor

@edewata edewata commented Sep 12, 2023

Previously after creating an ACME order the client would call ACMEAuthorizationService to poll the status of the authorization. Initially the authorization did not have any challenges, so this service would create the challenges for it. In subsequent calls this service would just return the status of the authorization.

When the client completes a challenge, the ACMEChallengeProcessor will update the authorization by removing the old challenges and adding the new ones. Since these operations are not atomic there is a risk that after the old challenges are removed the client will call the ACMEAuthorizationService and create new challenges which will never be completed by the client.

To avoid the problem, the code that creates the challenges has been moved from ACMEAuthorizationService into ACMENewOrderService so the challenges can only be created just once when the order is initially created.

The LDAPDatabase.addAuthorization() has also been updated to add the challenges after adding the authorization.

Copy link
Member

@fmarco76 fmarco76 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@ckelleyRH ckelleyRH left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@frasertweedale
Copy link
Contributor

this change makes sense to me.

Previously after creating an ACME order the client would call
ACMEAuthorizationService to poll the status of the authorization.
Initially the authorization did not have any challenges, so this
service would create the challenges for it. In subsequent calls
this service would just return the status of the authorization.

When the client completes a challenge, the ACMEChallengeProcessor
will update the authorization by removing the old challenges and
adding the new ones. Since these operations are not atomic there
is a risk that after the old challenges are removed the client
will call the ACMEAuthorizationService and create new challenges
which will never be completed by the client.

To avoid the problem, the code that creates the challenges has
been moved from ACMEAuthorizationService into ACMENewOrderService
so the challenges can only be created just once when the order is
initially created.

The LDAPDatabase.addAuthorization() has also been updated to add
the challenges after adding the authorization.
@edewata
Copy link
Contributor Author

edewata commented Sep 14, 2023

@fmarco76 @ckelleyRH @frasertweedale Thanks! I'll merge this one first.

@sonarcloud
Copy link

sonarcloud bot commented Sep 14, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@edewata edewata merged commit ed8e7f5 into dogtagpki:master Sep 14, 2023
150 of 151 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants