Miggo Logo

CVE-2022-0415: Unrestricted Upload of File with Dangerous Type in Gogs

8.8

CVSS Score
3.1

Basic Information

EPSS Score
0.99017%
Published
3/28/2022
Updated
1/27/2023
KEV Status
No
Technology
TechnologyGo

Technical Details

CVSS Vector
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H
Package NameEcosystemVulnerable VersionsFirst Patched Version
gogs.io/gogsgo< 0.12.60.12.6

Vulnerability Intelligence
Miggo AIMiggo AI

Miggo AIRoot 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.

Vulnerable functions

Only Mi**o us*rs **n s** t*is s**tion

WAF Protection Rules

WAF Rule

### Imp**t T** m*li*ious us*r is **l* to uplo** * *r**t** `*on*i*` *il* into r*pository's `.*it` *ir**tory wit* to **in SS* ****ss to t** s*rv*r. *ll inst*ll*tions wit* [r*pository uplo** *n**l** (****ult)](*ttps://*it*u*.*om/*o*s/*o*s/*lo*/********

Reasoning

T** vuln*r**ility st*ms *rom t** `Uplo**R*po*il*s` *un*tion's **ilur* to prop*rly `v*li**t*()` *ot* t** t*r**t *ir**tory (`Tr**P*t*`) *n* uplo**** `*il*n*m*s`. T** p*t** ***s two *riti**l ****ks: *) * `Tr**P*t*` v*li**tion usin* `isR*pository*itP*t*`