CVE-2022-0415: Unrestricted Upload of File with Dangerous Type in Gogs
8.8
CVSS Score
3.1
Basic Information
CVE ID
GHSA ID
EPSS Score
0.99017%
CWE
Published
3/28/2022
Updated
1/27/2023
KEV Status
No
Technology
Go
Technical Details
CVSS Vector
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H
Package Name | Ecosystem | Vulnerable Versions | First Patched Version |
---|---|---|---|
gogs.io/gogs | go | < 0.12.6 | 0.12.6 |
Vulnerability Intelligence
Miggo AI
Root Cause Analysis
The vulnerability stems from the UploadRepoFiles
function's failure to properly validate()
both the target directory (TreePath
) and uploaded filenames
. The patch adds two critical checks: 1) A TreePath
validation using isRepositoryGitPath
before processing uploads, and 2) Additional filename
sanitization and validation. The original code only had a late-stage .git
check that could be bypassed through path manipulation, as evidenced by the added pathutil.Clean
call in the patch. This function was the entry point for file uploads and contained the inadequate validation that enabled the .git
directory exploitation.