Miggo Logo

CVE-2024-54148:
Remote Command Execution in file editing in gogs

9.8

CVSS Score
3.1

Basic Information

EPSS Score
0.52494%
Published
12/23/2024
Updated
12/26/2024
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.13.10.13.1

Vulnerability Intelligence
Miggo AIMiggo AI

Miggo AIRoot Cause Analysis

The vulnerability stems from insufficient symlink validation during file rename operations in the web editor. The patch adds two critical symlink checks:

  1. When handling new file paths (entry.IsSymlink() check)
  2. When handling existing files during renames (entry.IsSymlink() check on oldTreePath)

The original vulnerable code in editFilePost only checked the new file path for symlinks, but didn't verify if the original file being renamed (oldTreePath) was a symlink. This allowed attackers to modify symlink targets by renaming them, bypassing security restrictions. The function's failure to validate both old and new paths for symlink status directly enabled the path traversal and RCE chain.

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 *ommit *n* **it * *r**t** symlink *il* to * r*pository to **in SS* ****ss to t** s*rv*r. ### P*t***s **itin* symlink w*il* ***n*in* t** *il* n*m* **s ***n pro*i*it** vi* t** r*pository w** **itor (*ttps://

Reasoning

T** vuln*r**ility st*ms *rom insu**i*i*nt symlink v*li**tion *urin* *il* r*n*m* op*r*tions in t** w** **itor. T** p*t** ***s two *riti**l symlink ****ks: *. W**n **n*lin* n*w *il* p*t*s (`*ntry.IsSymlink()` ****k) *. W**n **n*lin* *xistin* *il*s *uri