Skip to content

fix: bound debian ParseControlFile to a single control stanza#38044

Merged
lunny merged 3 commits into
go-gitea:mainfrom
metsw24-max:debian-control-single-stanza
Jun 10, 2026
Merged

fix: bound debian ParseControlFile to a single control stanza#38044
lunny merged 3 commits into
go-gitea:mainfrom
metsw24-max:debian-control-single-stanza

Conversation

@metsw24-max

Copy link
Copy Markdown
Contributor

Packages-index stanza injection via Debian control file

A .deb whose control file appends extra paragraphs after a blank line was still accepted, and ParseControlFile stored the whole multi-stanza blob in p.Control. That blob is re-emitted verbatim into the generated Packages index, so the embedded blank line splits it into separate stanzas and an uploader can smuggle a package entry with an attacker-chosen Filename into the shared index. A binary control file only holds one stanza, so parsing now stops at the blank line that terminates it; well-formed packages are unaffected and the new subtest covers the trailing-stanza case.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jun 9, 2026
Comment thread modules/packages/debian/metadata.go
Signed-off-by: wxiaoguang <wxiaoguang@gmail.com>
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Jun 9, 2026
@wxiaoguang wxiaoguang changed the title bound debian ParseControlFile to a single control stanza fix: bound debian ParseControlFile to a single control stanza Jun 9, 2026
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Jun 9, 2026
@lunny lunny added backport/v1.26 This PR should be backported to Gitea 1.26 reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. labels Jun 9, 2026
@lunny lunny merged commit 7134c1f into go-gitea:main Jun 10, 2026
24 checks passed
@GiteaBot GiteaBot added this to the 1.28.0 milestone Jun 10, 2026
@GiteaBot GiteaBot removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Jun 10, 2026
@GiteaBot GiteaBot added the backport/done All backports for this PR have been created label Jun 10, 2026
@wxiaoguang wxiaoguang modified the milestones: 1.28.0, 1.27.0 Jun 10, 2026
bircni added a commit that referenced this pull request Jun 14, 2026
#38055)

Backport #38044 by @metsw24-max

**Packages-index stanza injection via Debian control file**

A `.deb` whose `control` file appends extra paragraphs after a blank
line was still accepted, and `ParseControlFile` stored the whole
multi-stanza blob in `p.Control`. That blob is re-emitted verbatim into
the generated `Packages` index, so the embedded blank line splits it
into separate stanzas and an uploader can smuggle a package entry with
an attacker-chosen `Filename` into the shared index. A binary control
file only holds one stanza, so parsing now stops at the blank line that
terminates it; well-formed packages are unaffected and the new subtest
covers the trailing-stanza case.

Signed-off-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: metsw24-max <metsw24@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: bircni <bircni@icloud.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agentscan:automated-account backport/done All backports for this PR have been created backport/v1.26 This PR should be backported to Gitea 1.26 lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants