All Blogs
CWE/SANS Top 25 Most Dangerous Software Weaknesses: Complete List, Examples & Prevention

Quick Overview: Get the complete 2025 CWE Top 25 ranking and see how MITRE scores each weakness using CVE frequency and CVSS severity. All 25 weaknesses are grouped into four categories: injection, authorization and authentication, memory safety, and file, data, and resource handling. Each one comes with a clear description, a realistic example, and practical prevention steps you can implement.
Thousands of new vulnerabilities are disclosed every year. Look closely, and many of them come from the same few mistakes.
An input that never gets escaped. An API that forgets to check who's asking. A buffer copied without a size check.
The CWE Top 25 tracks exactly that pattern. For its 2025 list, MITRE analyzed the weaknesses behind 39,080 CVE records and ranked the ones that appeared most often and caused the most damage. Missing authorization climbed five places to fourth, and cross-site scripting stayed at number one.
For developers and security teams, this list works as a shortcut. Fix a weakness once, and you close off every future bug that would have come from it.
This guide covers all 25 weaknesses with real examples and practical prevention steps. It also shows how ZeroThreat's advanced web app pentesting tool helps catch flaws in running web apps and APIs.
Twenty-five dangerous weaknesses, one simple question: how many are live in your web app today? Find Out Free
On Ths Page
- What is the CWE/SANS Top 25?
- The 2025 CWE Top 25 List: Complete Ranking
- Injection Weaknesses: Examples and Prevention
- Authorization and Authentication Weaknesses: Examples and Prevention
- Memory Safety Weaknesses: Examples and Prevention
- File, Data, and Resource Handling Weaknesses: Examples and Prevention
- How the CWE Top 25 is Ranked
- CWE Top 25 vs OWASP Top 10: What's the Difference?
- How ZeroThreat Detects CWE Top 25 in Web Apps and APIs
- Wrapping Up
What is the CWE/SANS Top 25?
The CWE/SANS Top 25 is a yearly ranking of the 25 most dangerous software weaknesses: the coding and design mistakes behind the most common and most severe vulnerabilities in real software. MITRE maintains it as part of the Common Weakness Enumeration (CWE) program. The 2025 edition was released jointly by CISA and MITRE, who encourage organizations to use it to guide their software security strategies.
Each entry describes a type of weakness. CWE-89, for example, covers building a SQL query from user input without neutralizing special characters. A CVE is one occurrence of that mistake in a specific product. Because a single CWE can be the root cause of thousands of CVEs, fixing the underlying pattern removes an entire class of vulnerabilities at once.
"SANS" in the name comes from the list's origins. The SANS Institute proposed a focused Top 25 CWE list in 2008, and MITRE helped build the first edition, released in January 2009. The early editions were based on expert surveys. In 2019, MITRE moved to a data-driven method built on National Vulnerability Database records. Since then, the list has carried only the CWE name. "SANS Top 25 vulnerabilities," "SANS CWE Top 25," and "CWE Top 25 vulnerabilities" all refer to the same list.
The list is not limited to web applications. It also includes memory safety flaws common in C and C++ code, so it applies to developers, testers, and security teams working on almost any kind of software.
The 2025 CWE Top 25 List: Complete Ranking
The table below shows the full 2025 CWE Top 25 in ranking order, with each weakness's danger score, its number of CVEs in CISA's KEV catalog, and its movement since the 2024 list.
| Rank | CWE ID | Weakness | Score | CVEs in KEV | Change vs. 2024 |
|---|---|---|---|---|---|
| 1 | CWE-79 | Cross-Site Scripting (XSS) | 60.38 | 7 | No change |
| 2 | CWE-89 | SQL Injection | 28.72 | 4 | ▲ 1 |
| 3 | CWE-352 | Cross-Site Request Forgery (CSRF) | 13.64 | 0 | ▲ 1 |
| 4 | CWE-862 | Missing Authorization | 13.28 | 0 | ▲ 5 |
| 5 | CWE-787 | Out-of-Bounds Write | 12.68 | 12 | ▼ 3 |
| 6 | CWE-22 | Path Traversal | 8.99 | 10 | ▼ 1 |
| 7 | CWE-416 | Use After Free | 8.47 | 14 | ▲ 1 |
| 8 | CWE-125 | Out-of-Bounds Read | 7.88 | 3 | ▼ 2 |
| 9 | CWE-78 | OS Command Injection | 7.85 | 20 | ▼ 2 |
| 10 | CWE-94 | Code Injection | 7.57 | 7 | ▲ 1 |
| 11 | CWE-120 | Classic Buffer Overflow | 6.96 | 0 | New |
| 12 | CWE-434 | Unrestricted Upload of File with Dangerous Type | 6.87 | 4 | ▼ 2 |
| 13 | CWE-476 | NULL Pointer Dereference | 6.41 | 0 | ▲ 8 |
| 14 | CWE-121 | Stack-Based Buffer Overflow | 5.75 | 4 | New |
| 15 | CWE-502 | Deserialization of Untrusted Data | 5.23 | 11 | ▲ 1 |
| 16 | CWE-122 | Heap-Based Buffer Overflow | 5.21 | 6 | New |
| 17 | CWE-863 | Incorrect Authorization | 4.14 | 4 | ▲ 1 |
| 18 | CWE-20 | Improper Input Validation | 4.09 | 2 | ▼ 6 |
| 19 | CWE-284 | Improper Access Control | 4.07 | 1 | New |
| 20 | CWE-200 | Exposure of Sensitive Information to an Unauthorized Actor | 4.01 | 1 | ▼ 3 |
| 21 | CWE-306 | Missing Authentication for Critical Function | 3.47 | 11 | ▲ 4 |
| 22 | CWE-918 | Server-Side Request Forgery (SSRF) | 3.36 | 0 | ▼ 3 |
| 23 | CWE-77 | Command Injection | 3.15 | 2 | ▼ 10 |
| 24 | CWE-639 | Authorization Bypass Through User-Controlled Key | 2.62 | 0 | ▲ 6 |
| 25 | CWE-770 | Allocation of Resources Without Limits or Throttling | 2.54 | 0 | ▲ 1 |
Source: MITRE 2025 CWE Top 25. "New" means the weakness had no rank in the 2024 Top 25.
Missing authorization jumped to fourth. Test every role and login flow in the application where these flaws hide. Pentest My Web App
Injection Weaknesses: Examples and Prevention
Injection weaknesses happen when untrusted input reaches a query, command, or code interpreter and runs as instructions. Five weaknesses in the 2025 CWE Top 25 fall into this category, with cross-site scripting ranked first and SQL injection second.

CWE-79: Cross-Site Scripting (XSS)
Cross-site scripting occurs when an application puts user-controlled input into a web page without neutralizing it for the context where it renders. The victim's browser then runs the attacker's script with the site's privileges. That lets the attacker steal session tokens, perform actions as the user, or change page content. XSS comes in stored, reflected, and DOM-based forms.
Example: A product review field accepts a <script> tag that sends document.cookie to an external server. The application stores the review as-is, so every shopper who opens the product page runs the script and hands over their session cookie.
How to prevent it:
- Encode output for the context it lands in: HTML body, attribute, JavaScript, URL, or CSS.
- Use frameworks that escape output by default, and review every bypass such as dangerouslySetInnerHTML or |safe.
- Sanitize rich-text input with a vetted library such as DOMPurify instead of writing your own filters.
- Avoid dangerous DOM sinks like innerHTML, document.write(), and eval() in client-side code.
- Deploy a strict Content Security Policy that uses nonces or hashes to block inline scripts.
- Set session cookies with the HttpOnly, Secure, and SameSite flags to limit what a script can steal.
- Test client-side routes as well as server responses, because DOM-based XSS never reaches the server.
CWE-89: SQL Injection
SQL injection happens when an application builds a SQL query by concatenating user input, so the database parses part of that input as SQL syntax. Attackers can read or change data they shouldn't access and bypass authentication checks. Depending on the database and its configuration, they may also be able to run commands on the underlying server.
Example: A login form builds WHERE email = ' + input + ' AND password_hash = .... An attacker enters admin@site.com'--, which comments out the password check and logs them in as the administrator.
How to prevent it:
- Use parameterized queries or prepared statements for every query that includes external data.
- Use ORM query builders as designed, and avoid raw-query methods that take formatted strings.
- Allowlist values that can't be parameterized, such as column names, table names, and sort direction.
- Give the application's database account least privilege, with no schema-change or admin rights.
- Avoid building dynamic SQL inside stored procedures, which can be injectable too.
- Return generic error messages so database errors can't be used to extract data.
- Test for blind and time-based injection, not just injection that shows errors in the response.
CWE-78: OS Command Injection
OS command injection occurs when an application passes user input into a command run by the operating system shell without neutralizing shell metacharacters such as ;, |, &&, or backticks. An attacker can chain on their own commands and run them with the application's privileges. This often leads to full server compromise, which is why attackers exploit it so heavily.
Example: A network diagnostics page runs ping -c 4 + host. Submitting 8.8.8.8; cat /etc/passwd makes the shell run a second command and return the server's user list in the response.
How to prevent it:
- Use built-in language libraries instead of shelling out, for example a DNS library in place of calling nslookup.
- When an external program is unavoidable, call it with an argument array (execFile, or subprocess.run([...]) without shell=True).
- Validate input against a strict allowlist, such as a valid IP address or hostname pattern.
- Run the process under a low-privilege account inside a container or sandbox.
- Use escaping functions like escapeshellarg() only as a backup to argument arrays and allowlists.
- Alert on unexpected child processes started by web server or application processes.
CWE-77: Command Injection
Command injection is the broader parent of CWE-78. It covers any case where an application builds a command for another component, such as a CLI tool, mail server, or cache, using untrusted input that can change what the command does. Argument injection is a common form: the input adds options the developer never intended.
Example: A repository import feature runs git with a user-supplied URL. The attacker submits a value that starts with --upload-pack=, so git reads it as an option and runs an attacker-chosen program instead of cloning the repository.
How to prevent it:
- Pass user input as separate arguments, never as part of a concatenated command string.
- Add -- before user-supplied values to tell the tool that options have ended.
- Reject input that starts with - when a filename, URL, or ID is expected.
- Allowlist accepted formats, such as https:// URLs only or known identifier patterns.
- Strip CR and LF characters from values used in protocol commands for SMTP, IMAP, or Redis.
- Use native libraries or APIs instead of calling command-line tools whenever possible.
CWE-94: Code Injection
Code injection happens when an application builds code from user input and executes it in its own runtime. Typical paths are eval(), exec(), dynamic file includes, or server-side template rendering. Unlike OS command injection, the payload runs as code in the application's own language. That usually gives the attacker the same level of control the application has.
Example: A reporting tool evaluates user formulas with Python's eval(). Entering import('os').system('id') instead of price * 1.1 runs a system command on the server.
How to prevent it:
- Remove eval(), exec(), new Function(), and similar calls from any code path that handles external input.
- Use a purpose-built parser or a safe expression library for formulas, filters, and rules.
- Never render user input as a template; pass it to the template engine as data so it can't cause server-side template injection (SSTI).
- Parse structured data with JSON.parse() or json.loads() instead of evaluating it.
- Limit dynamic file includes and class loading to a fixed allowlist.
- Disable risky runtime features such as PHP's allow_url_include, and run interpreters with least privilege.
- Add dynamic execution sinks to SAST rules and code review checklists so new uses are flagged.
Authorization and Authentication Weaknesses: Examples and Prevention
Authorization and authentication weaknesses let attackers reach data or functions they shouldn't. Either the application never checks who the user is or what they're allowed to do, or it runs that check incorrectly. Six entries in the 2025 CWE Top 25 fall into this category, led by Missing Authorization, which climbed five places to fourth.

CWE-862: Missing Authorization
Missing authorization occurs when an application performs a sensitive action or returns protected data without checking whether the user making the request is allowed to. The user is usually logged in, but the endpoint never checks their role or permissions. It is common in APIs, admin functions, and endpoints that are hidden from the UI but left unprotected.
Example: A SaaS app hides the "Delete user" button from non-admins, but the DELETE /api/users/{id} endpoint has no role check. Any logged-in user who sends the request directly can delete other accounts.
How to prevent it:
- Enforce authorization on the server for every endpoint; hiding a feature in the UI does not protect it.
- Deny access by default, so new routes stay blocked until a policy explicitly allows them.
- Centralize checks in middleware, decorators, or a policy engine instead of repeating them in each handler.
- Maintain a matrix of which roles can reach which endpoints, and verify it in automated tests.
- Inventory every API, including undocumented and legacy versions, so no endpoint goes unprotected.
- Test every endpoint with low-privilege and unauthenticated sessions, not only admin sessions.
CWE-863: Incorrect Authorization
Incorrect authorization means the application does run an access check, but the check is wrong. It may rely on the wrong attribute, trust a role value the client supplied, skip a code path, or contain a logic error. An attacker who finds the gap can access resources or perform actions beyond their permissions.
Example: An app lets users approve refunds when user.department == "finance", but users can edit their own department in profile settings. A support agent changes it to "finance" and approves their own refund requests.
How to prevent it:
- Base access decisions only on server-side session data, never on headers, cookies, or form fields the client controls.
- Block users from editing attributes that drive access decisions, such as role, department, or tenant.
- Use a well-tested authorization library or policy engine instead of hand-written conditionals.
- Apply the same check on every path to a resource: web, API, mobile, and bulk export.
- Write negative test cases that confirm unauthorized roles are denied.
- Treat changes to authorization logic as security-sensitive code that requires review.
- Log and alert on denied access attempts and privilege changes.
CWE-284: Improper Access Control
Improper access control is the broad parent category for any failure to restrict who can reach a resource. It covers weaknesses in authentication, authorization, and accountability that don't fit a more specific CWE, such as overly broad permissions, exposed management interfaces, and services that trust any caller on the network.
Example: An internal billing microservice assumes only other internal services can call it, so it has no authentication. A misconfigured network rule exposes it to the internet, and anyone can call it to issue credits.
How to prevent it:
- Treat access control as a design requirement that covers users, service accounts, and admin interfaces.
- Apply least privilege to user roles, service accounts, files, and database permissions.
- Restrict management interfaces and internal services to trusted networks or a VPN.
- Authenticate service-to-service calls with mTLS or signed tokens; network location is not proof of identity.
- Remove default accounts and disable debug consoles before deploying.
- Review permissions regularly and revoke access that is no longer needed.
- Map each finding to a more specific CWE where possible so the root cause is clear.
CWE-639: Authorization Bypass Through User-Controlled Key
This weakness, usually called IDOR or BOLA, happens when an application uses an identifier from the request (an order ID, account number, or file name) to fetch a record without confirming that the record belongs to the requesting user. Changing the ID exposes or changes other users' data. It rose six places to 24th in 2025.
Example: A banking API returns statements from /api/statements/88412. A logged-in customer changes the number to 88413 and receives someone else's statement, because the server only checks for a valid session.
How to prevent it:
- Check object ownership or permission on the server for every read, update, and delete.
- Scope queries to the current user or tenant, for example WHERE id = ? AND owner_id = ?.
- Take the user's identity from the session, never from an ID passed in the request.
- Use random UUIDs instead of sequential IDs as defense in depth; they make guessing harder but don't replace ownership checks.
- Return the same 404 response for "not found" and "not yours" so attackers can't confirm which IDs are valid.
- Test with two accounts of the same role, swapping object IDs between them.
- Rate-limit and monitor sequential access across object IDs.
CWE-306: Missing Authentication for Critical Function
Missing authentication for critical function happens when an application exposes a function that changes data, configuration, or system state without requiring the caller to prove who they are. These are often internal APIs, setup endpoints, or device management interfaces assumed to be unreachable. Unlike missing authorization, no identity check happens at all. It has 11 CVEs in CISA's KEV catalog.
Example: An IoT gateway exposes POST /api/firmware/update for maintenance but never requires a login. Anyone who can reach the device over the network can upload modified firmware.
How to prevent it:
- Require authentication on every endpoint by default, with explicit exceptions for public routes.
- List your critical functions (password reset, configuration changes, user creation, firmware updates) and confirm each one requires login.
- Don't rely on obscure URLs or network location as the only protection.
- Disable installation and setup endpoints after first use, or require authentication for them.
- Require re-authentication or MFA for high-impact actions such as changing credentials or payout details.
- Enforce authentication in a central gateway or middleware instead of route by route.
- Scan externally for unauthenticated endpoints, including APIs missing from your documentation.
CWE-352: Cross-Site Request Forgery (CSRF)
Cross-site request forgery happens when an application accepts a state-changing request without verifying that the user meant to send it. Because browsers attach cookies automatically, a malicious site can make a logged-in victim's browser submit a request that the application treats as legitimate. Attackers use this to change email addresses, passwords, or account settings.
Example: A user stays logged in to their bank and then visits a malicious page. A hidden form on that page automatically submits POST /transfer with the attacker's account number. The bank sees a valid session cookie and processes the transfer.
How to prevent it:
- Use your framework's built-in anti-CSRF tokens on every state-changing request.
- Set session cookies to SameSite=Lax or SameSite=Strict.
- Never change state through GET requests.
- Check the Origin or Referer header on sensitive requests as an extra layer.
- Require re-authentication for critical actions such as changing a password, email, or payment details.
- For cookie-authenticated APIs, require a custom request header that a cross-site form cannot set.
New weaknesses ship with every release. Compare plans that keep testing in step with deployments. Check Out Pricing
Memory Safety Weaknesses: Examples and Prevention
Memory safety weaknesses occur when C, C++, or other native code reads, writes, or reuses memory outside the bounds or lifetime the program intended. Seven entries in the 2025 CWE Top 25 fall into this category, including use after free, which has 14 CVEs in CISA's KEV catalog.

CWE-125: Out-of-Bounds Read
An out-of-bounds read happens when a program reads data before the start or past the end of a buffer. The read usually comes from trusting a length or index without checking it. Attackers can use it to leak memory contents such as passwords, private keys, or session data, or to bypass ASLR as a first step in a larger exploit.
Example: Heartbleed (CVE-2014-0160) in OpenSSL trusted a length field in TLS heartbeat requests. Attackers claimed a large payload size, and the server copied up to 64 KB of adjacent memory back to them, including private keys and session data.
How to prevent it:
- Check every length and index against the real buffer size before reading.
- Never trust length fields from network packets or file headers; compare them with the amount of data actually received.
- Use bounds-checked access in C++, such as std::vector::at() or std::span.
- Fuzz parsers and protocol handlers with AddressSanitizer enabled.
- Turn on compiler warnings and static analysis rules for array indexing.
- Write new parsing code in memory-safe languages such as Rust, Go, or Java.
CWE-787: Out-of-Bounds Write
An out-of-bounds write happens when a program writes data past the end or before the start of a buffer. This corrupts nearby memory, such as variables, heap metadata, or function pointers. Depending on what gets overwritten, the result can be a crash, data corruption, or code execution. It ranks fifth in 2025 and has 12 CVEs in KEV.
Example: An image decoder reads width and height from a file header and allocates width * height bytes. A crafted file makes the multiplication overflow to a small number, so writing the pixel data runs past the end of the buffer.
How to prevent it:
- Check the arithmetic used to size buffers for integer overflow before allocating.
- Confirm the destination has enough space before every write, loop, or copy.
- Compile with -D_FORTIFY_SOURCE=2 or higher to catch some overflows at runtime.
- Keep platform protections such as ASLR, DEP/NX, and control-flow integrity enabled.
- Run fuzzing with AddressSanitizer as part of CI.
- Move high-risk components such as parsers, codecs, and network handlers to memory-safe languages.
CWE-120: Classic Buffer Overflow
A classic buffer overflow occurs when a program copies input into a fixed-size buffer without first checking that the input fits. Unbounded C functions such as strcpy, strcat, and gets are the usual cause, because they keep copying until the source ends, whatever the destination size. It entered the Top 25 at 11th in 2025.
Example: A login service runs strcpy(name, username) to copy a username into char name[32]. A 200-character username keeps writing past the buffer and overwrites the memory next to it.
How to prevent it:
- Ban unbounded functions such as strcpy, strcat, sprintf, and gets.
- Use size-aware alternatives such as snprintf and strlcpy, or std::string in C++.
- Pass the destination buffer size explicitly into every copy routine.
- Reject input that exceeds the expected length before copying it.
- Enforce the banned-function list with compiler warnings or static analysis in CI.
CWE-121: Stack-Based Buffer Overflow
A stack-based buffer overflow happens when an overflow hits a buffer on the call stack, usually a local array inside a function. The stack also holds return addresses and saved registers, so overwriting it can let an attacker redirect execution when the function returns. Modern compiler and OS protections make this harder to exploit, but they don't remove the flaw.
Example: A web server function declares char path[256] on the stack and copies the request path into it with sprintf. An oversized path overwrites the saved return address, and execution can jump to an attacker-chosen address when the function returns.
How to prevent it:
- Compile with stack canaries using -fstack-protector-strong.
- Keep ASLR and non-executable stack protections enabled.
- Avoid large fixed-size stack arrays for external input; size buffers from validated lengths.
- Never use variable-length arrays or alloca() with sizes controlled by input.
- Enable shadow stacks, such as Intel CET, where the platform supports them.
- Fuzz functions that copy external input into local buffers.
CWE-122: Heap-Based Buffer Overflow
A heap-based buffer overflow happens when an overflow hits memory allocated dynamically, for example with malloc or new. It can corrupt nearby objects, allocator metadata, or function pointers that the program uses later. Heap overflows are often harder to detect than stack overflows because the damage shows up later, away from the faulty write. It has 6 CVEs in KEV.
Example: A file parser allocates a buffer using a size field from the file header, then copies the actual body, which is larger. The extra bytes overwrite a function pointer in a neighboring object, which the program later calls.
How to prevent it:
- Size allocations from the actual data length, not from header values the attacker controls.
- Use hardened allocators that detect heap metadata corruption.
- Enable hardware memory tagging, such as ARM MTE, where it's available.
- Run AddressSanitizer during testing to catch heap overflows at the point of the write.
- Keep function pointers and other sensitive objects away from buffers that hold attacker-controlled data.
- Use RAII containers that track their own size instead of raw buffers.
CWE-416: Use After Free
Use after free happens when a program keeps using a pointer after the memory it points to has been freed. If the allocator has since reused that memory for attacker-controlled data, the program acts on the attacker's data. This often leads to code execution, which is why use after free shows up so often in browser and kernel exploits.
Example: A chat server frees a user's session object when they disconnect, but a pending message handler still holds a pointer to it. When the handler runs, it reads memory that now contains data the attacker sent.
How to prevent it:
- Use smart pointers such as std::unique_ptr and std::shared_ptr to tie object lifetime to ownership.
- Set pointers to NULL immediately after freeing them.
- Define clear ownership rules for objects shared across callbacks, threads, or event handlers.
- Cancel pending callbacks and timers before freeing the objects they reference.
- Catch use-after-free bugs in testing with AddressSanitizer and fuzzing.
- Write new components in Rust, whose borrow checker rejects use-after-free at compile time.
CWE-476: NULL Pointer Dereference
A NULL pointer dereference occurs when a program uses a pointer that holds NULL as if it pointed to valid memory. In most environments this crashes the process, so the main impact is denial of service. Some older kernels let attackers map memory at address zero and turn the bug into code execution. It rose eight places to 13th in 2025.
Example: A network service looks up a session by token and uses the result without checking it. Sending an invalid token makes the lookup return NULL, which crashes the service. An attacker can repeat this to keep the service down.
How to prevent it:
- Check the return value of every function that can return NULL before using it.
- Use static analysis that flags possible NULL dereferences.
- Use references or std::optional in C++ so "no value" is handled explicitly.
- Return an error response instead of crashing when a lookup finds nothing.
- Fuzz with malformed input to reach rare error paths.
- Run services under a supervisor that restarts them, and alert on repeated crashes.
File, Data, and Resource Handling Weaknesses: Examples and Prevention
File, data, and resource handling weaknesses happen when an application trusts input that controls file paths, uploaded content, serialized objects, outbound requests, or resource use. Seven entries in the 2025 CWE Top 25 fall into this group. Path traversal has 10 CVEs in CISA's KEV catalog, and deserialization of untrusted data has 11.

CWE-22: Path Traversal
Path traversal occurs when an application builds a file path from user input without making sure the result stays inside the intended directory. Sequences such as ../, or absolute paths, let an attacker move up the directory tree. From there they can read configuration files, credentials, or source code, and sometimes write files outside the intended folder.
Example: A document portal serves files through /download?file=report.pdf. Requesting /download?file=../../../etc/passwd makes the server join that value onto its base folder and return the system's user file.
How to prevent it:
- Map user requests to file IDs on the server instead of accepting file names or paths.
- Canonicalize the final path (realpath, Path.resolve()) and confirm it still starts with the allowed base directory.
- Reject input containing .., path separators, null bytes, or absolute paths.
- Decode input fully before validating it, so encoded forms such as %2e%2e%2f can't get past the check.
- Run the application under an account that can read only the folders it needs.
- Use a chroot, container, or object storage to limit what a traversal can reach.
CWE-434: Unrestricted Upload of File with Dangerous Type
Unrestricted file upload happens when an application accepts uploaded files without properly checking their type, content, or where they are stored. If an attacker uploads a server-side script into a directory the web server executes, they get remote code execution. Even without execution, uploads can deliver malware or stored XSS to other users.
Example: A profile picture feature checks only the browser-supplied Content-Type header. An attacker uploads avatar.php labeled as image/png, it lands in the public /uploads/ folder, and opening its URL runs the attacker's code on the server.
How to prevent it:
- Allowlist permitted file extensions, and check the file's magic bytes against the declared type.
- Rename uploaded files to random names, and never reuse the name the user supplied.
- Store uploads outside the web root or in object storage that never executes code.
- Disable script execution in any directory that holds user uploads.
- Serve user files from a separate domain with Content-Disposition: attachment.
- Enforce file size limits and scan uploads for malware before processing them.
CWE-502: Deserialization of Untrusted Data
Insecure deserialization occurs when an application rebuilds objects from serialized data that an attacker can control. Native formats such as Java serialization, Python pickle, PHP unserialize, and .NET BinaryFormatter can create arbitrary object types during deserialization. Combined with "gadget" classes already on the classpath, this often leads to remote code execution before the application ever validates the object.
Example: A Java app stores session state in a cookie as a Base64-encoded serialized object. An attacker replaces it with a crafted object chain built from a library on the classpath, and the server executes commands the moment it deserializes the cookie.
How to prevent it:
- Don't use native serialization for data that crosses a trust boundary; use JSON or Protocol Buffers with a strict schema.
- Where native deserialization is unavoidable, restrict allowed classes with an allowlist filter, such as Java's ObjectInputFilter.
- Sign serialized data with an HMAC and verify the signature before deserializing.
- Use safe loaders such as yaml.safe_load() in Python, and never call pickle.loads() on external input.
- Keep libraries patched, since public gadget chains rely on common dependencies.
- Run deserializing services with least privilege to limit the damage if exploitation succeeds.
CWE-918: Server-Side Request Forgery (SSRF)
Server-side request forgery happens when an application fetches a URL supplied by the user without restricting where the request can go. The attacker makes the server send requests on their behalf, reaching internal services, admin panels, or cloud metadata endpoints that aren't exposed to the internet. In cloud environments, SSRF is a common way to steal credentials.
Example: A link preview feature fetches any URL a user posts. An attacker submits http://169.254.169.254/latest/meta-data/iam/security-credentials/, and the server returns temporary cloud credentials from the instance metadata service.
How to prevent it:
- Allowlist the domains or hosts the application actually needs to reach.
- Resolve the hostname and block private, loopback, and link-local IP ranges before sending the request.
- Disable automatic redirects, or re-check the destination after each redirect and DNS lookup.
- Require IMDSv2 or equivalent token-based metadata access in cloud environments.
- Restrict outbound traffic from application servers with egress firewall rules.
- Don't return raw response bodies from fetched URLs to the user.
- Run URL-fetching features in an isolated service with no access to internal networks.
CWE-20: Improper Input Validation
Improper input validation is a broad parent weakness. It occurs when an application doesn't check that input has the expected type, range, length, format, or business meaning before using it. It underlies many more specific weaknesses on this list. It dropped six places to 18th in 2025, likely because more CVEs were mapped to precise child weaknesses.
Example: A checkout API trusts the quantity value sent by the client. An attacker submits -5 for an expensive item, the order total goes negative, and the payment system issues a credit to the attacker's account.
How to prevent it:
- Validate every input on the server, even when the client already checks it.
- Define strict schemas for requests (OpenAPI or JSON Schema) and reject anything that doesn't match.
- Check type, length, range, and format, and use allowlists over denylists.
- Validate business rules too: quantities must be positive, and dates must fall within allowed windows.
- Canonicalize input before validating it so encoded variants can't bypass checks.
- Reject invalid input instead of trying to clean it up.
- Centralize validation logic so every endpoint applies the same rules.
CWE-200: Exposure of Sensitive Information to an Unauthorized Actor
Sensitive information exposure occurs when an application reveals data to someone who shouldn't see it. Common causes are verbose error messages, API responses that return entire database objects, debug endpoints left enabled, and secrets in logs. The leaked data often helps attackers plan further attacks, even when it's not damaging on its own.
Example: A /api/users/me endpoint returns the full user record, including password_hash, mfa_secret, and internal role flags. The frontend shows only the name and email, but anyone inspecting the API response sees everything.
How to prevent it:
- Return explicit response objects (DTOs) that include only the fields the client needs.
- Show users generic error messages and keep stack traces in server-side logs.
- Disable debug modes, admin consoles, and verbose headers in production.
- Mask or exclude passwords, tokens, and personal data from application logs.
- Scan code repositories, build artifacts, and logs for exposed secrets.
- Classify sensitive data so developers know which fields must never leave the server.
- Review API responses during testing, not just the UI.
CWE-770: Allocation of Resources Without Limits or Throttling
This weakness occurs when an application lets users consume memory, CPU, storage, connections, or API calls without any limit. An attacker, or simply a heavy user, can exhaust those resources and slow down or crash the service for everyone. It's a common root cause of application-layer denial of service, especially in APIs. It ranks 25th in 2025.
Example: A search API accepts a limit parameter with no maximum. A request with limit=10000000 makes the server load millions of rows into memory, which exhausts the heap and crashes the service.
How to prevent it:
- Enforce maximum page sizes and default to small result sets.
- Apply rate limits per user, API key, and IP address.
- Set limits on request body size, upload size, and the number of fields in a request.
- Add timeouts to database queries, outbound calls, and long-running jobs.
- Limit GraphQL query depth and complexity.
- Set CPU and memory limits on containers and quotas per tenant.
- Use bounded queues and connection pools instead of letting them grow without limit.
How the CWE Top 25 is Ranked
Each weakness gets a danger score that combines two things: how often it appears in published CVE records, and how severe those CVEs are on average. The 25 highest scores make the list.
The 2025 ranking was built from 39,080 CVE Records published between June 1, 2024 and June 1, 2025. Only records with a CVSS v3.0 or v3.1 base score were included. MITRE then calculates the score in three steps:
- Frequency (Fr) = Number of CVE mappings to the CWE, min-max normalized
- Severity (Sv) = Average CVSS base score of those CVEs, min-max normalized
- Danger Score = Fr × Sv × 100
Because the two values are multiplied, a weakness needs both volume and impact to rank high. The scoring penalizes weaknesses that are rare as well as those with low impact, so the top scores go to weaknesses that are both common and seriously harmful. That explains why cross-site scripting sits at number one with a score of 60.38, more than double second place. XSS isn't the most severe weakness on the list, but it shows up in an enormous number of CVEs.
CWE Top 25 vs OWASP Top 10: What's the Difference?
The CWE Top 25 ranks 25 specific software weaknesses across all types of software, using CVE data. The OWASP Top 10 groups web application security risks into 10 broad categories. Together, the 10 categories in its 2025 edition cover 248 CWEs. Use OWASP to prioritize risks and the CWE Top 25 to fix code.
| Aspect | CWE Top 25 | OWASP Top 10 |
|---|---|---|
| Maintained by | MITRE, with CISA | OWASP Foundation |
| Scope | All software, including web, native, embedded, and OS code | Web applications |
| What it ranks | 25 individual weaknesses (root causes) | 10 risk categories, each grouping many CWEs |
| Ranking basis | Frequency × CVSS severity across public CVE records | Contributed application testing data plus a community survey |
| Memory safety coverage | Yes (7 entries in 2025) | Not a dedicated category |
| Update cycle | Every year | About every four years (2017, 2021, 2025) |
| Best used for | Secure coding standards, SAST/DAST rule mapping, and fixing specific weaknesses | Security awareness, setting AppSec program priorities, and compliance baselines |
How ZeroThreat Detects CWE Top 25 in Web Apps and APIs
ZeroThreat tests running web apps and APIs the way an attacker would. It combines AI penetration testing with more than one lakh checks detecting the CWE/SANS Top 25, OWASP Top 10, and real-time CVEs. Each finding includes reproducible exploit proof, with the request, response, and exact payload, so teams can confirm a weakness is exploitable before they fix it.
Authorization weaknesses such as CWE-862, CWE-863, and CWE-639 only appear behind a login. ZeroThreat runs authenticated testing across auth flows, SSO, MFA, and role-based access. It also validates BOLA and BFLA in REST, GraphQL, and SOAP APIs, discovers shadow endpoints, and tests workflows for flaws like price manipulation and race conditions.
Findings come with AI-generated, code-level fix guidance and can be sent as tickets to Jira, GitHub, or GitLab. CI/CD integrations can block releases that have critical findings, rate-limited probing keeps production scans safe, and automated retesting confirms each fix before closing the issue.
You've seen all 25 weaknesses. Now find out which ones your own application is carrying. Test My App Now
Wrapping Up
The CWE Top 25 works best as a map of root causes. Its entries fall into four families: injection, broken authorization and authentication, memory safety, and unsafe handling of files, data, and resources. Each family has a consistent fix pattern that teams can build into coding standards and code reviews.
A weakness's rank alone should not decide what gets fixed first. The rank reflects how common and severe a weakness is across published CVEs, while CISA's KEV catalog shows what attackers actually exploit. OS command injection ranks ninth but has 20 CVEs in KEV, the most of any entry.
Most tools don't cover all 25 weaknesses. While ZeroThreat's AI penetration testing tool exposes and validates all types of vulnerabilities including OWASP Top 10, CVEs, and zero-day flaws as well.
If you are looking to strengthen the security of your web application by eliminating each and every risk that can turn into a threat, sign up with ZeroThreat now!
Frequently Asked Questions
Is the SANS Top 25 the same as the CWE Top 25?
Yes. Both names refer to the same list. The SANS Institute co-created it with MITRE, releasing the first edition in January 2009. Since MITRE switched to a data-driven method in 2019, it has been published as the CWE Top 25 Most Dangerous Software Weaknesses. "SANS Top 25" is still a common search term.
How often is the CWE Top 25 updated?
Which CWE Top 25 weaknesses are most exploited by attackers?
Explore ZeroThreat
Automate security testing, save time, and avoid the pitfalls of manual work with ZeroThreat.


