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.)
Weak Password Requirements
This vulnerability occurs when an application fails to enforce strong password policies, making user accounts easier to compromise through guessing or automated attacks.
What is CWE-521?
Real-world CVEs caused by CWE-521
-
key server application does not require strong passwords
Step-by-step attacker path
- 1
Identify a code path that handles untrusted input without validation.
- 2
Craft a payload that exercises the unsafe behavior — injection, traversal, overflow, or logic abuse.
- 3
Deliver the payload through a normal request and observe the application's reaction.
- 4
Iterate until the response leaks data, executes attacker code, or escalates privileges.
Vulnerable pseudo
MITRE has not published a code example for this CWE. The pattern below is illustrative — see Resources for canonical references.
// Example pattern — see MITRE for the canonical references.
function handleRequest(input) {
// Untrusted input flows directly into the sensitive sink.
return executeUnsafe(input);
} Secure pseudo
// Validate, sanitize, or use a safe API before reaching the sink.
function handleRequest(input) {
const safe = validateAndEscape(input);
return executeWithGuards(safe);
} How to prevent CWE-521
- Architecture and Design A product's design should require adherance to an appropriate password policy. Specific password requirements depend strongly on contextual factors, but it is recommended to contain the following attributes: - Enforcement of a minimum and maximum length - Restrictions against password reuse - Restrictions against using common passwords - Restrictions against using contextual string in the password (e.g., user id, app name) Depending on the threat model, the password policy may include several additional attributes. - Complex passwords requiring mixed character sets (alpha, numeric, special, mixed case) - Increasing the range of characters makes the password harder to crack and may be appropriate for systems relying on single factor authentication. - Unfortunately, a complex password may be difficult to memorize, encouraging a user to select a short password or to incorrectly manage the password (write it down). - Another disadvantage of this approach is that it often does not result in a significant increases in overal password complexity due to people's predictable usage of various symbols. 1. Large Minimum Length (encouraging passphrases instead of passwords) - Increasing the number of characters makes the password harder to crack and may be appropriate for systems relying on single factor authentication. - A disadvantage of this approach is that selecting a good passphrase is not easy and poor passwords can still be generated. Some prompting may be needed to encourage long un-predictable passwords. 1. Randomly Chosen Secrets - Generating a password for the user can help make sure that length and complexity requirements are met, and can result in secure passwords being used. - A disadvantage of this approach is that the resulting password or passpharse may be too difficult to memorize, encouraging them to be written down. See NIST 800-63B [REF-1053] for further information on password requirements.
- Architecture and Design Consider a second authentication factor beyond the password, which prevents the password from being a single point of failure. See CWE-308 for further information.
- Implementation Consider implementing a password complexity meter to inform users when a chosen password meets the required attributes.
- Implementation Previously, "password expiration" was widely advocated as a defense-in-depth approach to minimize the risk of weak passwords, and it has become a common practice. Password expiration requires a password to be changed within a fixed time window (such as every 90 days). However, this approach has significant limitations in the current threat landscape, and its utility has been reduced in light of the adoption of related protection mechanisms (such as password complexity and computational effort), along with the recognition that regular password changes often caused users to generate more predictable passwords. As a result, this is now a Discouraged Common Practice [REF-1488] [REF-1489], especially as the sole factor in protecting passwords. It is still strongly encouraged to force password changes in case of evidence of compromise, but this is not the same as a forced "expiration" on an arbitrary time frame.
How to detect CWE-521
Plexicus auto-detects CWE-521 and opens a fix PR in under 60 seconds.
Codex Remedium scans every commit, identifies this exact weakness, and ships a reviewer-ready pull request with the patch. No tickets. No hand-offs.
Frequently asked questions
What is CWE-521?
This vulnerability occurs when an application fails to enforce strong password policies, making user accounts easier to compromise through guessing or automated attacks.
How serious is CWE-521?
MITRE has not published a likelihood-of-exploit rating for this weakness. Treat it as medium-impact until your threat model proves otherwise.
What languages or platforms are affected by CWE-521?
MITRE lists the following affected platforms: Not Technology-Specific.
How can I prevent CWE-521?
A product's design should require adherance to an appropriate password policy. Specific password requirements depend strongly on contextual factors, but it is recommended to contain the following attributes: - Enforcement of a minimum and maximum length - Restrictions against password reuse - Restrictions against using common passwords - Restrictions against using contextual string in the password (e.g., user id, app name) Depending on the threat model, the password policy may include several…
How does Plexicus detect and fix CWE-521?
Plexicus's SAST engine matches the data-flow signature for CWE-521 on every commit. When a match is found, our Codex Remedium agent opens a fix PR with the corrected code, tests, and a one-line summary for the reviewer.
Where can I learn more about CWE-521?
MITRE publishes the canonical definition at https://cwe.mitre.org/data/definitions/521.html. You can also reference OWASP and NIST documentation for adjacent guidance.
Weaknesses related to CWE-521
Use of Weak Credentials
This vulnerability occurs when a system relies on weak authentication credentials—like default passwords, hard-coded keys, or easily…
Use of Default Credentials
This vulnerability occurs when a system, device, or application relies on pre-configured, publicly known credentials like passwords or…
Use of Hard-coded Credentials
This vulnerability occurs when software contains built-in, unchangeable authentication secrets like passwords or encryption keys within…
Empty Password in Configuration File
This vulnerability occurs when a configuration file, script, or application uses an empty string as a password, effectively disabling…
Further reading
- MITRE — official CWE-521 https://cwe.mitre.org/data/definitions/521.html
- Digital Identity Guidelines (SP 800-63B) https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-63b.pdf
- Digital Identity Guidelines (SP 800-63B-4) https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-63B-4.pdf
- Password Guidance: Simplifying Your Approach https://assets.publishing.service.gov.uk/media/5a806bb9e5274a2e87db9b6a/Password_guidance_-_simplifying_your_approach.pdf
Don't Let Security
Weigh You Down.
Stop choosing between AI velocity and security debt. Plexicus is the only platform that runs Vibe Coding Security and ASPM in parallel — one workflow, every codebase.