CVE-2021-27116: Privilege escalation in beego

github.com/beego/beego/v2 Updated 02 Oct 2025

Summary

06/04/2022
Yes i
High
7.8

CVE-2021-27116: Privilege escalation in beego. Affects github.com/beego/beego/v2 versions >= 2.0.0, < 2.0.2. Fixed in 2.0.2. How to fix ↓

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Devnack Mobile apps built by Devnack Design, build and launch iOS and Android apps with a senior product team. From idea to store release Start a project

Background

Beego is a popular open-source framework for building web applications and APIs in the Go programming language. It provides a robust set of tools and features to simplify the development process. However, a vulnerability has been discovered in beego that allows for privilege escalation.

Vulnerability Detail

The vulnerability (CVE-2021-27116) exists in the file profile.go. The MemProf and GetCPUProfile functions in beego do not properly check whether the created file already exists. This oversight enables attackers to launch symlink attacks locally, potentially leading to privilege escalation. By exploiting this vulnerability, attackers can gain elevated privileges and perform unauthorized actions on the affected system.

How To Fix

Latest published version: v2.3.10 as of 23 Oct 2026

go get github.com/beego/beego/v2@v2.3.10

Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.

If you need the minimum change

2.0.2

This is the first release that contains the fix.

go get github.com/beego/beego/v2@v2.0.2

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

If updating to the latest version of beego is not immediately feasible, a temporary workaround can be implemented. This involves manually modifying the affected code in profile.go to include proper file existence checks before creating the file. Here is an example of the modified code:

// Check if the file already exists
if _, err := os.Stat(filePath); err == nil {
    // File already exists, handle accordingly
    return
}

// Create the file
file, err := os.Create(filePath)
if err != nil {
    // Error handling
    return
}
defer file.Close()

Conclusion

The vulnerability (CVE-2021-27116) in beego allows for privilege escalation through symlink attacks. It is crucial to update to beego version 2.0.2 or later to mitigate this vulnerability. If immediate updating is not possible, implementing the provided workaround can help protect against potential attacks. For further support and assistance in vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for github.com/beego/beego/v2 →

Share this vulnerability

FAQ

Beego is an open-source framework for building web applications and APIs in the Go programming language. It provides a range of tools and features to simplify the development process.

Privilege escalation is the act of gaining elevated privileges on a system or application. In the context of this vulnerability, it refers to an attacker being able to escalate their privileges and perform unauthorized actions.

This vulnerability can be exploited by launching symlink attacks locally. By creating symbolic links to sensitive files, an attacker can trick the beego framework into performing unauthorized actions and potentially gain elevated privileges.

Yes, the beego development team has released a fix for this vulnerability in version 2.0.2. It is recommended to update to the latest version to ensure the vulnerability is patched.

If updating to the latest version of beego is not immediately feasible, a temporary workaround can be implemented by modifying the affected code to include proper file existence checks before creating the file. Refer to the 'workaround' section for more details.

Related vulnerabilities

Recent vulnerabilities recorded for github.com/beego/beego/v2.

How To Fix

Latest published version: v2.3.10 as of 23 Oct 2026

go get github.com/beego/beego/v2@v2.3.10

Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.

If you need the minimum change

2.0.2

This is the first release that contains the fix.

go get github.com/beego/beego/v2@v2.0.2

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback