CVE-2021-27116
Executive Summary
CVE-2021-27116 is a local symlink attack vulnerability in the beego web application framework (through version 2.0.2). The flaw resides in the function MemProf within the file profile.go, allowing an attacker with local access to the system to perform symlink-based attacks, potentially leading to arbitrary file read/write, privilege escalation, or data tampering on the hosting system.
Applications built on beego versions up to and including 2.0.2 that expose the memory profiling functionality are affected. The CVSS base score of 7.8 reflects the high confidentiality, integrity, and availability impacts achievable through this local attack vector. No public exploit code, patch, or CISA KEV listing exists for this CVE as of the analysis date.
This record — and 170,000+ others — are available via the ValtersIT API. One endpoint replaces five: NVD + GitHub CVE + CISA KEV + EPSS + Nuclei + Exploit-DB, unified.
No signup required
Technical Analysis
The vulnerability is present in the beego web application framework, specifically in the MemProf function implemented within the profile.go file. The NVD description indicates that the issue "allows attackers to launch symlink attacks locally."
Symlink attacks (CWE-59: Improper Link Resolution Before File Access) occur when an application creates, writes to, or reads from a file without properly validating that the target path does not resolve through a symbolic link. In the context of MemProf, which is responsible for generating memory profile dumps, the function likely creates output files (e.g., memory profile snapshots) in a predictable location or with a predictable filename. If an attacker can pre-create a symlink at that expected path pointing to a sensitive file elsewhere on the system, the MemProf function will follow the symlink and overwrite or read the target file with the privileges of the beego application process.
The attack surface is local: the attacker must have user-level access to the host system where the beego application runs, and must be able to place files in the directory where MemProf writes its output. The impact severity is elevated if the beego application runs with elevated privileges (e.g., as root or a service account with broad filesystem permissions), as the symlink target could be a critical system file such as /etc/passwd, /etc/shadow, or application configuration files.
Insufficient technical detail is available in the NVD description to provide a more granular code-level explanation, such as the exact file path construction logic, whether the output filename includes a timestamp (which would make symlink pre-creation timing-dependent), or the specific file permissions applied to the generated profile dump. The vulnerability class, however, is well understood: predictable file path combined with improper symlink validation.
Exploitation Scenarios
Scenario 1: Arbitrary File Overwrite via Predictable Profile Path
Reconnaissance: The attacker, already authenticated as a local user, enumerates running processes to identify beego applications. This can be done via
ps aux | grep beegoor by examining listening ports (ss -tlnp). The attacker notes the working directory of the beego process and its effective user ID.Trigger: The attacker identifies the location where
MemProfwrites its memory profile output. Based on the function name and common profiling conventions, this is likely a file such asmem.proforprofile.outin the application's working directory or a configurable output path. The attacker pre-creates a symbolic link at that exact location pointing to a sensitive target file (e.g.,/etc/cron.d/backdooror/home/victim/.ssh/authorized_keys) usingln -s /etc/cron.d/backdoor /app/mem.prof.Payload/Execution: The attacker waits for or forces the memory profiling operation to be triggered. This could occur through an HTTP endpoint (e.g.,
/debug/pprof/heapin Go applications that importnet/http/pprof) or through an application-level administrative command. WhenMemProfwrites the memory profile dump, it follows the symlink and writes the profiling data to the target file, overwriting its contents.Post-Exploitation: The attacker now has written arbitrary binary/text data to a sensitive file. Depending on the target, this could result in: (a) corruption of a configuration file leading to denial of service, (b) overwriting of an executable or script with attacker-controlled content leading to code execution when the file is next invoked, or (c) if the memory profile itself is parsed by other tooling, malicious content could be embedded to trigger secondary vulnerabilities.
Scenario 2: Information Disclosure via Profile File Read
- Reconnaissance: Same as above.
- Trigger: The attacker creates a symlink from a predictable
MemProfoutput path to a sensitive file containing credentials or configuration secrets (e.g.,/etc/nginx/nginx.confor application database credentials file). - Payload/Execution: When
MemProfattempts to read existing profiling data (some profilers read prior dumps for comparison) or if the application's error handling exposes file contents, the symlink resolution causes the sensitive file to be read. - Post-Exploitation: The attacker obtains sensitive data from the target file.
Note: No public PoC is available; the attack chain is inferred from the vulnerability class (symlink attack) described in the NVD entry and standard symlink exploitation techniques.
Impact Assessment
| Aspect | Assessment |
|---|---|
| CVSS Base Score | 7.8 (High) — driven by High impact to Confidentiality, Integrity, and Availability (all C:I:A = H) |
| Attack Vector | Local (AV:L) — requires local user access; not remotely exploitable over the network |
| Attack Complexity | Low (AC:L) — no special conditions required beyond user-level access |
| Privileges Required | Low (PR:L) — attacker needs a local user account |
| User Interaction | None (UI:N) — the attack is triggered by the application performing its normal profiling function |
| Affected Systems | Any beego-based application version ≤ 2.0.2 that invokes MemProf with insufficient filesystem path validation |
| Business Impact | Undermines data integrity (config/credential corruption), confidentiality (file read), and availability (process crash or system file corruption). In environments where beego apps run as root or systemd services, impact escalates to full system compromise potential |
| Blast Radius | Limited to the local host; does not propagate to other network segments. However, a single compromised host in a Kubernetes cluster or microservices architecture could serve as a pivot point for lateral movement |
The absence of CISA KEV listing and public PoC suggests limited real-world exploitation observed to date. However, the vulnerability is trivial to exploit once the code path is understood, and the EPSS score of 0.00432 (35.7th percentile) indicates low-but-nonzero likelihood of exploitation in the wild.
Detection Guidance
Sigma Rule
title: Beego MemProf Symlink Attack - Suspicious Symlink Creation
id: a1b2c3d4-e5f6-7890-abcd-ef1234567890
status: experimental
description: Detects creation of symlinks pointing to sensitive system files in directories where Beego applications write profiling data
logsource:
category: process_creation
product: linux
detection:
selection_lna:
Image|endswith: '/ln'
CommandLine|contains|all:
- '-s'
- '/etc/'
selection_dirs:
CommandLine|contains|all:
- 'profile'
- '.prof'
- 'mem'
condition: selection_lna and selection_dirs
fields:
- CommandLine
- User
- ParentImage
falsepositives:
- Legitimate symlink creation by system administrators
- Deployment scripts creating links to profile directories
level: medium
What is this? Security researchers use these exact search queries on Shodan.io (a search engine for internet-connected devices) to find vulnerable systems globally. You can copy these dorks to see if your organization's IP space is exposed.