Miggo Logo

CVE-2022-1986:
OS Command Injection in file editor in Gogs

9.8

CVSS Score
3.1

Basic Information

EPSS Score
0.94526%
Published
6/8/2022
Updated
1/27/2023
KEV Status
No
Technology
TechnologyGo

Technical Details

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

Vulnerability Intelligence
Miggo AIMiggo AI

Miggo AIRoot Cause Analysis

The vulnerability stems from improper path sanitization in the isRepositoryGitPath function. The original implementation used string(os.PathSeparator) which could be bypassed by using mixed path separators. The patch explicitly checks for both '/' and '\' separators, indicating the previous implementation failed to properly validate paths across different OS environments. This allowed attackers to manipulate .git directory contents (like SSH authorized_keys or hooks), leading to OS command injection through subsequent Git operations.

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 up**t* * *r**t** `*on*i*` *il* into r*pository's `.*it` *ir**tory in *om*in*tion wit* *r**t** *il* **l*tion to **in SS* ****ss to t** s*rv*r. *ll inst*ll*tions wit* [r*pository uplo** *n**l** (****ult)](*ttps

Reasoning

T** vuln*r**ility st*ms *rom improp*r p*t* s*nitiz*tion in t** `isR*pository*itP*t*` *un*tion. T** ori*in*l impl*m*nt*tion us** `strin*(os.P*t*S*p*r*tor)` w*i** *oul* ** *yp*ss** *y usin* mix** p*t* s*p*r*tors. T** p*t** *xpli*itly ****ks *or *ot* `'