Skip to content

Race condition: consent-status derivation reads stale auth-resource state outside transaction in authresource service #45

Description

@coderabbitai

Summary

In consent-server/internal/authresource/service.go, both CreateAuthResource and UpdateAuthResource read auth-resource state (via store.GetByConsentID and s.stores.Consent.GetByID) before calling ExecuteTransaction. The derived consent status is then used inside the transaction to conditionally update consent status. Because the read happens outside the transaction boundary, concurrent writes can make the snapshot stale by commit time, potentially leading to incorrect consent status derivation.

Affected methods

  • CreateAuthResource — approximately lines 124–147
  • UpdateAuthResource — approximately lines 319–344

Expected fix

Move the auth-resource state reads (store.GetByConsentID, s.stores.Consent.GetByID) and the call to validator.EvaluateConsentStatusFromAuthStatuses inside the ExecuteTransaction callback so the snapshot and derived consent status are computed atomically within the transaction boundary.

References

Reported by @hasithakn

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions