Repository navigation
fix: store link tokens encrypted in job arguments - #299
Open
jaspermayone wants to merge 1 commit into
Open
jaspermayone wants to merge 1 commit into
jaspermayone wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to GHSA-3rx4-8wxp-j549 and #298.
Problem
MagicLinkJoband the mail jobs ofGuardianConsentMailercarried the raw link token as a plain-text job argument. The queue table and/admin/jobsthus held a usable link. #298 deletes finished rows after one day, but a failed job is not finished, so its row kept the token with no time limit.Change
LinkToken(lib/link_token.rb) wraps a raw link token. Its Active Job serializer stores the token encrypted (AES-256-GCM, key derived fromsecret_key_base).User#send_magic_link, and the request and receipt mails inGuardianConsentFlow.MagicLinkJobandTokenMailDeliveryJobrefuse a plainStringtoken at enqueue, so a new caller that does not wrap the token fails at once.to_param.A failed token job can now stay in
/admin/jobsfor a retry, because its row holds no usable token.Deploy notes
/admin/jobs.secret_key_base, a token job that is still in the queue fails.Checks
bundle exec rspec: 2955 examples, 0 failures.bin/rubocop: no offenses.bin/brakeman: 0 warnings.bin/rails zeitwerk:check: passed.