# CVE-2023-4039: GCC's-fstack-protector fails to guard dynamically-sized local variables on AArch64

> GCC's stack protector fails to detect overflows in dynamically-sized local variables on AArch64, allowing attackers to bypass security checks and potentially execute code.

- **Severity:** Medium 4.8 (`CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:L/A:N`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 13 Sep 2023
- **Updated:** 14 Oct 2026
- **Also known as:** ALPINE-CVE-2023-4039, AZL-28769, AZL-34695, DEBIAN-CVE-2023-4039, ECHO-4f67-4add-cfdb, MINI-8q24-vc8f-v8x5, OESA-2023-1735, OESA-2025-1042, SUSE-SU-2023:3640-1, SUSE-SU-2023:3661-1, SUSE-SU-2023:3686-1, SUSE-SU-2023:4162-1, SUSE-SU-2023:4458-1, SUSE-SU-2023:4480-1, SUSE-SU-2024:0045-1, UBUNTU-CVE-2023-4039, USN-7700-1, openSUSE-SU-2024:13233-1, openSUSE-SU-2024:13234-1, openSUSE-SU-2024:13235-1

## What is CVE-2023-4039?

CVE-2023-4039 is a medium-severity vulnerability in Arm GNU Toolchain, published on 13 Sep 2023. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

**DISPUTED**A failure in the -fstack-protector feature in GCC-based toolchains 
that target AArch64 allows an attacker to exploit an existing buffer 
overflow in dynamically-sized local variables in your application 
without this being detected. This stack-protector failure only applies 
to C99-style dynamically-sized local variables or those created using 
alloca(). The stack-protector operates as intended for statically-sized 
local variables.

The default behavior when the stack-protector 
detects an overflow is to terminate your application, resulting in 
controlled loss of availability. An attacker who can exploit a buffer 
overflow without triggering the stack-protector might be able to change 
program flow control to cause an uncontrolled loss of availability or to
 go further and affect confidentiality or integrity. NOTE: The GCC project argues that this is a missed hardening bug and not a vulnerability by itself.

Weakness: CWE-693 (Protection Mechanism Failure)

## Which versions are affected by CVE-2023-4039?

It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `cross-nvptx-gcc12` | SUSE:Enterprise Storage 7 | All versions | 12.3.0+git1204-150000.1.16.1 |
| `gcc12` | SUSE:Enterprise Storage 7 | All versions | 12.3.0+git1204-150000.1.16.1 |
| `cross-nvptx-gcc13` | SUSE:Enterprise Storage 7.1 | All versions | 13.2.1+git7813-150000.1.6.1 |
| `gcc13` | SUSE:Enterprise Storage 7.1 | All versions | 13.2.1+git7813-150000.1.6.1 |
| `cross-nvptx-gcc12` | SUSE:Linux Enterprise High Performance Computing 15 SP1-LTSS | All versions | 12.3.0+git1204-150000.1.16.1 |
| `cross-nvptx-gcc13` | SUSE:Linux Enterprise High Performance Computing 15 SP1-LTSS | All versions | 13.2.1+git7813-150000.1.6.1 |
| `gcc12` | SUSE:Linux Enterprise High Performance Computing 15 SP1-LTSS | All versions | 12.3.0+git1204-150000.1.16.1 |
| `gcc12-testresults` | SUSE:Linux Enterprise High Performance Computing 15 SP1-LTSS | All versions | 12.3.0+git1204-150000.1.16.1 |
| `gcc13` | SUSE:Linux Enterprise High Performance Computing 15 SP1-LTSS | All versions | 13.2.1+git7813-150000.1.6.1 |
| `cross-nvptx-gcc12` | SUSE:Linux Enterprise High Performance Computing 15 SP2-LTSS | All versions | 12.3.0+git1204-150000.1.16.1 |
| `cross-nvptx-gcc13` | SUSE:Linux Enterprise High Performance Computing 15 SP2-LTSS | All versions | 13.2.1+git7813-150000.1.6.1 |
| `gcc12` | SUSE:Linux Enterprise High Performance Computing 15 SP2-LTSS | All versions | 12.3.0+git1204-150000.1.16.1 |
| `gcc13` | SUSE:Linux Enterprise High Performance Computing 15 SP2-LTSS | All versions | 13.2.1+git7813-150000.1.6.1 |
| `cross-nvptx-gcc12` | SUSE:Linux Enterprise High Performance Computing 15 SP3-ESPOS | All versions | 12.3.0+git1204-150000.1.16.1 |
| `cross-nvptx-gcc13` | SUSE:Linux Enterprise High Performance Computing 15 SP3-ESPOS | All versions | 13.2.1+git7813-150000.1.6.1 |
| `gcc12` | SUSE:Linux Enterprise High Performance Computing 15 SP3-ESPOS | All versions | 12.3.0+git1204-150000.1.16.1 |
| `gcc13` | SUSE:Linux Enterprise High Performance Computing 15 SP3-ESPOS | All versions | 13.2.1+git7813-150000.1.6.1 |
| `cross-nvptx-gcc12` | SUSE:Linux Enterprise High Performance Computing 15 SP3-LTSS | All versions | 12.3.0+git1204-150000.1.16.1 |
| `cross-nvptx-gcc13` | SUSE:Linux Enterprise High Performance Computing 15 SP3-LTSS | All versions | 13.2.1+git7813-150000.1.6.1 |
| `gcc12` | SUSE:Linux Enterprise High Performance Computing 15 SP3-LTSS | All versions | 12.3.0+git1204-150000.1.16.1 |
| `gcc13` | SUSE:Linux Enterprise High Performance Computing 15 SP3-LTSS | All versions | 13.2.1+git7813-150000.1.6.1 |
| `gcc12` | SUSE:Linux Enterprise Installer Updates 15 SP1 | All versions | 12.3.0+git1204-150000.1.16.1 |
| `gcc13` | SUSE:Linux Enterprise Installer Updates 15 SP1 | All versions | 13.2.1+git7813-150000.1.6.1 |
| `gcc12` | SUSE:Linux Enterprise Installer Updates 15 SP2 | All versions | 12.3.0+git1204-150000.1.16.1 |
| `gcc13` | SUSE:Linux Enterprise Installer Updates 15 SP2 | All versions | 13.2.1+git7813-150000.1.3.3 |
| `gcc13` | SUSE:Linux Enterprise Installer Updates 15 SP2 | All versions | 13.2.1+git7813-150000.1.6.1 |
| `gcc12` | SUSE:Linux Enterprise Installer Updates 15 SP3 | All versions | 12.3.0+git1204-150000.1.16.1 |
| `gcc13` | SUSE:Linux Enterprise Installer Updates 15 SP3 | All versions | 13.2.1+git7813-150000.1.3.3 |
| `gcc13` | SUSE:Linux Enterprise Installer Updates 15 SP3 | All versions | 13.2.1+git7813-150000.1.6.1 |
| `gcc12` | SUSE:Linux Enterprise Installer Updates 15 SP4 | All versions | 12.3.0+git1204-150000.1.16.1 |
| `gcc13` | SUSE:Linux Enterprise Installer Updates 15 SP4 | All versions | 13.2.1+git7813-150000.1.3.3 |
| `gcc13` | SUSE:Linux Enterprise Installer Updates 15 SP4 | All versions | 13.2.1+git7813-150000.1.6.1 |
| `gcc13` | SUSE:Linux Enterprise Installer Updates 15 SP5 | All versions | 13.2.1+git7813-150000.1.3.3 |
| `gcc13` | SUSE:Linux Enterprise Installer Updates 15 SP5 | All versions | 13.2.1+git7813-150000.1.6.1 |
| `gcc12` | SUSE:Linux Enterprise Micro 5.1 | All versions | 12.3.0+git1204-150000.1.16.1 |
| `gcc13` | SUSE:Linux Enterprise Micro 5.1 | All versions | 13.2.1+git7813-150000.1.3.3 |
| `gcc13` | SUSE:Linux Enterprise Micro 5.1 | All versions | 13.2.1+git7813-150000.1.6.1 |
| `gcc12` | SUSE:Linux Enterprise Micro 5.2 | All versions | 12.3.0+git1204-150000.1.16.1 |
| `gcc13` | SUSE:Linux Enterprise Micro 5.2 | All versions | 13.2.1+git7813-150000.1.3.3 |
| `gcc13` | SUSE:Linux Enterprise Micro 5.2 | All versions | 13.2.1+git7813-150000.1.6.1 |

Products: Gnu Gcc.

## How do I fix CVE-2023-4039?

Apply the vendor's patch.

## Is CVE-2023-4039 being exploited?

It is not confirmed as exploited in the wild, but public exploit code for CVE-2023-4039 exists.

## Other vulnerabilities in Arm GNU Toolchain

- [CVE-2018-12886](https://insights.sbomify.com/CVE-2018-12886/): Security feature bypass in n/a (high 8.1)
- [CVE-2002-2439](https://insights.sbomify.com/CVE-2002-2439/): Integer overflow in the new[] operator in gcc before 4.8.0 allows attackers to have unspecified impacts. (high 7.8)
- [CVE-2019-15847](https://insights.sbomify.com/CVE-2019-15847/): Weak cryptography in n/a (high 7.5)
- [CVE-2008-1367](https://insights.sbomify.com/CVE-2008-1367/): Memory corruption in n/a (high 7.5)
- [CVE-2008-1685](https://insights.sbomify.com/CVE-2008-1685/): Integer overflow in n/a (medium 6.8)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2023-4039 and fix it if it is affected.

What it is: CVE-2023-4039 is a medium-severity vulnerability in Arm GNU Toolchain, published on 13 Sep 2023. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: It is not confirmed as exploited in the wild, but public exploit code for CVE-2023-4039 exists.

Affected product: Arm GNU Toolchain. No package-level version data is available, so check the vendor advisory linked from the reference page.

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2023-4039/ (Markdown: https://insights.sbomify.com/CVE-2023-4039/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2023-4039
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2023-4039
- OSV: https://osv.dev/vulnerability/CVE-2023-4039

---
From sbomify Insights: https://insights.sbomify.com/CVE-2023-4039/
Summaries are generated and may contain mistakes; the official description above is the record.
