CWE-467: Use of sizeof() on a Pointer Type
The code calls sizeof() on a pointer type, which can be an incorrect calculation if the programmer intended to determine the size of the data that is being pointed to.
Last updated
Overview
The use of sizeof() on a pointer can sometimes generate useful information. An obvious case is to find out the wordsize on a platform. More often than not, the appearance of sizeof(pointer) indicates a bug.
Real-world CVEs
3 recorded CVEs are caused by CWE-467 (Use of sizeof() on a Pointer Type). The highest-severity and most recent are shown first. 1 new CWE-467 CVE has been recorded so far in 2026 (1 in 2025).
- CVE-2020-1638
Junos OS & Junos OS Evolved: A specific IPv4 packet can lead to FPC restart.
High · CVSS 7.5 · EPSS 69th2020-04-08 - CVE-2025-33132
Fixes to common vulnerabilities found in IBM Db2 High Performance Unload
Medium · CVSS 6.5 · EPSS 21th2025-10-27 - CVE-2026-52761
ModSecurity: Transformation utf8toUnicode produces wrong output on i386 architecture
Medium · CVSS 5.8 · EPSS 34th2026-07-10
Common consequences
What can happen when CWE-467 is exploited.
Modify Memory, Read Memory
Affects: Integrity, Confidentiality
This error can often cause one to allocate a buffer that is much smaller than what is needed, leading to resultant weaknesses such as buffer overflows.
How it happens
When it is introduced
Typically introduced during these phases of the software lifecycle.
Applies to
Languages
How to prevent it
Practical mitigations for CWE-467, grouped by where in the lifecycle they apply.
Use expressions such as "sizeof(*pointer)" instead of "sizeof(pointer)", unless you intend to run sizeof() on a pointer type to gain some platform independence or if you are allocating a variable on the stack.
How to detect it
Automated Static Analysis
Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then searching for potentially-vulnerable patterns that connect "sources" (origins of input) with "sinks" (destinations where the data interacts with external components, a lower layer such as the OS, etc.)
Effectiveness: High
Code examples
Illustrative examples from MITRE showing how the weakness appears in code.
Care should be taken to ensure sizeof returns the size of the data structure itself, and not the size of the pointer to the data structure.
Vulnerable example
double *foo;Safe example
double *foo;This example defines a fixed username and password. The AuthenticateUser() function is intended to accept a username and a password from an untrusted user, and check to ensure that it matches the username and password. If the username and password match, AuthenticateUser() is intended to indicate that authentication succeeded.
Vulnerable example
/* Ignore CWE-259 (hard-coded password) and CWE-309 (use of password system for authentication) for this example. */Attack input
pass5Terminology & mappings
Mapped taxonomies
- CLASP: Use of sizeof() on a pointer type
- CERT C Secure Coding: Do not apply the sizeof operator to a pointer when taking the size of an array (ARR01-C)
- CERT C Secure Coding: Allocate sufficient memory for an object (MEM35-C) — CWE More Abstract fit
- Software Fault Patterns: Incorrect Buffer Length Computation (SFP10)
Frequently asked questions
Common questions about CWE-467.
- What is CWE-467?
- The code calls sizeof() on a pointer type, which can be an incorrect calculation if the programmer intended to determine the size of the data that is being pointed to.
- What CVEs are caused by CWE-467?
- 3 recorded CVEs are attributed to CWE-467, including CVE-2020-1638, CVE-2025-33132, CVE-2026-52761.
- How do you prevent CWE-467?
- Use expressions such as "sizeof(*pointer)" instead of "sizeof(pointer)", unless you intend to run sizeof() on a pointer type to gain some platform independence or if you are allocating a variable on the stack.
- How is CWE-467 detected?
- Automated Static Analysis: Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then searching for potentially-vulnerable patterns that connect "sources" (origins of input) with "sinks" (destinations where the data interacts with external components, a lower layer such as the OS, etc.)
- What are the consequences of CWE-467?
- Exploiting CWE-467 can lead to: Modify Memory, Read Memory.
- Is CWE-467 actively exploited?
- 3 recorded CVEs are caused by CWE-467; none are currently in CISA's KEV catalog of actively exploited flaws.
References
- MITRE CWE definition (CWE-467) (opens in a new tab)
- CWE-467 vulnerabilities on NVD (opens in a new tab)
- Learn: What is a CWE?
Weakness data is sourced from the MITRE CWE catalog (v4.20). CVE associations are aggregated and kept current by RadicalNotion.AI.
Stay ahead of CWE-467
Get alerted the moment a new CWE-467 vulnerability affects your stack, with AI-written analysis, severity context, and remediation guidance.