CVE-2021-27116: Privilege escalation in beego
Summary
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 ↓
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.
No signup required · Results in about 60 seconds
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 →
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.
References
Related vulnerabilities
Recent vulnerabilities recorded for github.com/beego/beego/v2.