# Feedback requested on backup resume security review

**URL:** <https://meta.discourse.org/t/feedback-requested-on-backup-resume-security-review/417918>\
**Category:** Development\
**Tags:** backups\
**Created:** [20 november 2026 om 09:41 UTC](https://meta.discourse.org/t/feedback-requested-on-backup-resume-security-review/417918 "2026-11-20T09:41:04Z")\
**Posts on this page:** 1\
**Page:** 1

## AI-generated summary

[Ethsim2](/t/-/417918/1) requests feedback on an automated security review finding for the proposed backup download resume feature. The concern is that a previously authorized resume token could potentially be used to access a new file if a backup is deleted and replaced with another file sharing the same filename.

Ethsim2 notes that Discourse's automatically generated backup filenames include timestamps down to the second, making accidental reuse unlikely. The reported scenario requires an authenticated administrator session, a valid resume grant, and a filename collision, which typically only occurs if an admin manually uploads a backup with an existing filename. This means the filename alone does not guarantee immutable file identity.

Given that resumable downloads are disabled by default and the resume window is time-limited, Ethsim2 seeks maintainers' opinions on whether this represents a sufficiently realistic risk to warrant implementing additional file-identity verification. They ask whether it is reasonable to accept and document this residual risk or if verification is mandatory before merging. The goal is to find a balance between security, implementation complexity, and the feature's original purpose of enabling the resumption of interrupted large backup downloads.

<div class="post-metadata">

**Author:** ![Ethsim2](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ethsim2/32/522255_2.png) [@Ethsim2](https://meta.discourse.org/u/Ethsim2)\
**Post date:** [20 november 2026 om 09:41 UTC](https://meta.discourse.org/t/feedback-requested-on-backup-resume-security-review/417918/1 "2026-11-20T09:41:04Z")

</div>

I’ve received an automated security review finding on the proposed backup download resume PR:

> <https://github.com/discourse/discourse/pull/43041#discussion_r4588428167>
>
> \[1\] \*\*Error\*\*: The grant is scoped to a filename, not to the file version at tha…t name. It is never invalidated when \`destroy\` removes the local file, and the supported chunk-upload flow (\`HandleChunkUpload#merge\_chunks\`) explicitly deletes and rewrites the destination under the same filename. An attacker with this administrator's authenticated session and still-live resume URL can therefore wait for a different backup to be uploaded at that name, then issue \`Range: bytes=1-\` and receive the replacement without a fresh emailed token; for a \`.tar.gz\`, the omitted first byte is fixed, so the archive is reconstructable. This violates the stated same-backup boundary and can expose the replacement database/uploads. Bind the grant to an immutable file identity/fingerprint and verify it before serving (and invalidate grants on every delete/replacement path), rather than treating the filename as the backup identity.
> 
> \<details\>
> \<summary\>Fix with AI\</summary\>
> 
> \`\`\`\`text
> Investigate and resolve the following reported finding.
> 
> Repository: discourse/discourse
> Reviewed head: 7e372b946265b6a3ab55bef8e3b26c747d354a25
> Source: https://github.com/discourse/discourse/pull/43041
> Location: lib/backup\_download\_resume\_token.rb:5
> 
> Published finding:
> \[1\] \*\*Error\*\*: The grant is scoped to a filename, not to the file version at that name. It is never invalidated when \`destroy\` removes the local file, and the supported chunk-upload flow (\`HandleChunkUpload#merge\_chunks\`) explicitly deletes and rewrites the destination under the same filename. An attacker with this administrator's authenticated session and still-live resume URL can therefore wait for a different backup to be uploaded at that name, then issue \`Range: bytes=1-\` and receive the replacement without a fresh emailed token; for a \`.tar.gz\`, the omitted first byte is fixed, so the archive is reconstructable. This violates the stated same-backup boundary and can expose the replacement database/uploads. Bind the grant to an immutable file identity/fingerprint and verify it before serving (and invalidate grants on every delete/replacement path), rather than treating the filename as the backup identity.
> 
> Bounded actual source excerpt from reviewed HEAD 7e372b946265b6a3ab55bef8e3b26c747d354a25, around lib/backup\_download\_resume\_token.rb:1-10 (long lines may be truncated):
> \`\`\`
> \# frozen\_string\_literal: true
> 
> class BackupDownloadResumeToken
> def self.key(user\_id, backup\_filename)
> filename\_digest = Digest::SHA256.hexdigest(backup\_filename)
> "backup-download-resume-token:#{user\_id}:#{filename\_digest}"
> end
> 
> def self.set(user\_id, backup\_filename, token, ttl:)
> return if ttl.to\_i \<= 0
> \`\`\`
> 
> Acceptance is the reported behavior in the published finding, not merely that existing tests pass.
> Before changing code, reproduce the behavior or narrow it to the exact code path and mechanism; state what you confirmed. Do not invent unsupported reproduction evidence.
> If the finding is valid, identify the root cause and add a focused regression test that demonstrably fails before the fix and passes after it. If that is impractical, explain why and provide the strongest targeted verification available.
> Implement the smallest root-cause-focused fix. Do not perform adjacent refactors or unrelated cleanup.
> If the finding is a false positive, do not change the code; reject it with concrete evidence. Existing tests passing is not sufficient evidence.
> Run the relevant tests and checks. Report the exact commands and results, plus any behavior you could not verify.
> Preserve any reproduction evidence already present in the published finding, but do not seek, expose, copy, or publish private artifacts or internal assessment material, and do not expand the finding's visibility.
> \`\`\`\`
> \</details\>

The finding concerns the possibility of a previously authorised resume token being used after a backup has been deleted and another file uploaded under the same filename.

My understanding is that Discourse’s automatically generated backup filenames include a timestamp down to the second, making accidental reuse unlikely during normal backup creation.

The reported scenario also appears to require an authenticated administrator’s session, a still-valid resume grant and replacement of a backup under the same filename.

I recognise that manually uploaded backup files can reuse an existing filename, and therefore that the filename alone does not provide an immutable file identity.

However, I would appreciate the maintainers’ views on whether this represents a sufficiently realistic risk to require additional file-identity verification, particularly given that resumable downloads are disabled by default and the enabled resume window is time-limited.

Would it be reasonable to accept and document this residual risk, or would maintainers consider file-identity verification necessary before the feature could be merged?

I’d be interested in finding an appropriate balance between security, implementation complexity and the original aim of allowing interrupted large backup downloads to resume.
