Repository navigation
End sessions on password change, restrict SES webhook topics, images-only upload - #18
Merged
Merged
Conversation
…ages-only upload - Users get a token_version (V3 migration), carried in every JWT as "ver". Changing, resetting or admin-resetting a password raises it, and JwtAuthFilter refuses tokens from an older version, so a password change signs the user out everywhere. change-password returns a fresh token next to its message. Tokens issued before this change count as version 0 and keep working until they expire. - /webhooks/ses accepts only the SNS topics in SES_SNS_TOPIC_ARNS (403 otherwise). A valid signature only proves a message came from SNS, not from our topic. Unset, any topic is accepted and a warning is logged. - Template image uploads must be PNG, JPEG, GIF or WebP, recognised from the file's own bytes. The S3 key extension and Content-Type come from that, never from the client, so HTML or SVG can't be hosted on the public bucket.
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.
Fixes the second batch of audit findings.
Problems
Changes
users.token_versionis a new column (V3__user_token_version.sql), and every JWT carries it in averclaim.JwtAuthFilterthen refuses tokens with an older version, which also reduces token parsing from two passes to one.POST /api/auth/change-passwordstill returnsmessage, plustoken,user,expiresInandmustChangePassword. The client should replace its token with the new one; a client that doesn't gets a 401 and logs in again once.ver, count as version 0, and keep working until they expire.SES_SNS_TOPIC_ARNS(app.ses.sns-topic-arns), a comma-separated list. Messages from other topics get 403.ImageTypesrecognises PNG, JPEG, GIF and WebP from the file's first bytes. SVG is excluded on purpose.TemplateService.uploadImagerejects anything else with 400. It checks that a bucket is configured first, so an unconfigured server still answers 503.S3Service.uploadBytesstores the file under a random name with the detected extension and content type, andContent-Disposition: inline. It replacesuploadFile, which had no other callers.SES_SNS_TOPIC_ARNSand the SNS setup step.Deploy notes
V3runs at startup.SES_SNS_TOPIC_ARNSto your SES topic ARN(s).Testing
./gradlew test,integrationTestandscaleTestall pass locally.verclaim, including old tokens without it;