CWE-648 – Incorrect Use of Privileged APIs

Read Time:1 Minute, 43 Second

Description

The application does not conform to the API requirements for a function call that requires extra privileges. This could allow attackers to gain privileges by causing the function to be called incorrectly.

Modes of Introduction:

– Architecture and Design

 

Likelihood of Exploit: Low

 

Related Weaknesses

CWE-269

 

Consequences

Access Control: Gain Privileges or Assume Identity

An attacker may be able to elevate privileges.

Confidentiality: Read Application Data

An attacker may be able to obtain sensitive information.

Integrity, Confidentiality, Availability: Execute Unauthorized Code or Commands

An attacker may be able to execute code.

 

Potential Mitigations

Phase: Implementation

Description: 

Before calling privileged APIs, always ensure that the assumptions made by the privileged code hold true prior to making the call.

Phase: Architecture and Design

Description: 

Know architecture and implementation weaknesses of the privileged APIs and make sure to account for these weaknesses before calling the privileged APIs to ensure that they can be called safely.

Phase: Implementation

Description: 

If privileged APIs make certain assumptions about data, context or state validity that are passed by the caller, the calling code must ensure that these assumptions have been validated prior to making the call.

Phase: Implementation

Description: 

If privileged APIs do not shed their privilege prior to returning to the calling code, then calling code needs to shed these privileges immediately and safely right after the call to the privileged APIs. In particular, the calling code needs to ensure that a privileged thread of execution will never be returned to the user or made available to user-controlled processes.

Phase: Implementation

Description: 

Only call privileged APIs from safe, consistent and expected state.

Phase: Implementation

Description: 

Ensure that a failure or an error will not leave a system in a state where privileges are not properly shed and privilege escalation is possible (i.e. fail securely with regards to handling of privileges).

CVE References

  • CVE-2003-0645
    • A Unix utility that displays online help files, if installed setuid, could allow a local attacker to gain privileges when a particular file-opening function is called.

CWE-647 – Use of Non-Canonical URL Paths for Authorization Decisions

Read Time:48 Second

Description

The software defines policy namespaces and makes authorization decisions based on the assumption that a URL is canonical. This can allow a non-canonical URL to bypass the authorization.

Modes of Introduction:

– Architecture and Design

 

Likelihood of Exploit: High

 

Related Weaknesses

CWE-863

 

Consequences

Access Control: Bypass Protection Mechanism

An attacker may be able to bypass the authorization mechanism to gain access to the otherwise-protected URL.

Confidentiality: Read Files or Directories

If a non-canonical URL is used, the server may choose to return the contents of the file, instead of pre-processing the file (e.g. as a program).

 

Potential Mitigations

Phase: Architecture and Design

Description: 

Make access control policy based on path information in canonical form. Use very restrictive regular expressions to validate that the path is in the expected form.

Phase: Architecture and Design

Description: 

Reject all alternate path encodings that are not in the expected canonical form.

CVE References

CWE-646 – Reliance on File Name or Extension of Externally-Supplied File

Read Time:1 Minute, 30 Second

Description

The software allows a file to be uploaded, but it relies on the file name or extension of the file to determine the appropriate behaviors. This could be used by attackers to cause the file to be misclassified and processed in a dangerous fashion.

An application might use the file name or extension of of a user-supplied file to determine the proper course of action, such as selecting the correct process to which control should be passed, deciding what data should be made available, or what resources should be allocated. If the attacker can cause the code to misclassify the supplied file, then the wrong action could occur. For example, an attacker could supply a file that ends in a “.php.gif” extension that appears to be a GIF image, but would be processed as PHP code. In extreme cases, code execution is possible, but the attacker could also cause exhaustion of resources, denial of service, exposure of debug or system data (including application source code), or being bound to a particular server side process. This weakness may be due to a vulnerability in any of the technologies used by the web and application servers, due to misconfiguration, or resultant from another flaw in the application itself.

Modes of Introduction:

– Architecture and Design

 

Likelihood of Exploit: High

 

Related Weaknesses

CWE-345

 

Consequences

Confidentiality: Read Application Data

An attacker may be able to read sensitive data.

Availability: DoS: Crash, Exit, or Restart

An attacker may be able to cause a denial of service.

Access Control: Gain Privileges or Assume Identity

An attacker may be able to gain privileges.

 

Potential Mitigations

Phase: Architecture and Design

Description: 

Make decisions on the server side based on file content and not on file name or extension.

CVE References

CWE-644 – Improper Neutralization of HTTP Headers for Scripting Syntax

Read Time:45 Second

Description

The application does not neutralize or incorrectly neutralizes web scripting syntax in HTTP headers that can be used by web browser components that can process raw headers, such as Flash.

Modes of Introduction:

– Architecture and Design

 

Likelihood of Exploit: High

 

Related Weaknesses

CWE-116

 

Consequences

Integrity, Confidentiality, Availability: Execute Unauthorized Code or Commands

Run arbitrary code.

Confidentiality: Read Application Data

Attackers may be able to obtain sensitive information.

 

Potential Mitigations

Phase: Architecture and Design

Description: 

Perform output validation in order to filter/escape/encode unsafe data that is being passed from the server in an HTTP response header.

Phase: Architecture and Design

Description: 

Disable script execution functionality in the clients’ browser.

CVE References

  • CVE-2006-3918
    • Web server does not remove the Expect header from an HTTP request when it is reflected back in an error message, allowing a Flash SWF file to perform XSS attacks.

CWE-643 – Improper Neutralization of Data within XPath Expressions (‘XPath Injection’)

Read Time:54 Second

Description

The software uses external input to dynamically construct an XPath expression used to retrieve data from an XML database, but it does not neutralize or incorrectly neutralizes that input. This allows an attacker to control the structure of the query.

The net effect is that the attacker will have control over the information selected from the XML database and may use that ability to control application flow, modify logic, retrieve unauthorized data, or bypass important checks (e.g. authentication).

Modes of Introduction:

– Implementation

 

Likelihood of Exploit: High

 

Related Weaknesses

CWE-943
CWE-91

 

Consequences

Access Control: Bypass Protection Mechanism

Controlling application flow (e.g. bypassing authentication).

Confidentiality: Read Application Data

The attacker could read restricted XML content.

 

Potential Mitigations

Phase: Implementation

Description: 

Use parameterized XPath queries (e.g. using XQuery). This will help ensure separation between data plane and control plane.

Phase: Implementation

Description: 

Properly validate user input. Reject data where appropriate, filter where appropriate and escape where appropriate. Make sure input that will be used in XPath queries is safe in that context.

CVE References

CWE-642 – External Control of Critical State Data

Read Time:3 Minute, 42 Second

Description

The software stores security-critical state information about its users, or the software itself, in a location that is accessible to unauthorized actors.

Modes of Introduction:

– Architecture and Design

 

Likelihood of Exploit: High

 

Related Weaknesses

CWE-668

 

Consequences

Access Control: Bypass Protection Mechanism, Gain Privileges or Assume Identity

An attacker could potentially modify the state in malicious ways. If the state is related to the privileges or level of authentication that the user has, then state modification might allow the user to bypass authentication or elevate privileges.

Confidentiality: Read Application Data

The state variables may contain sensitive information that should not be known by the client.

Availability: DoS: Crash, Exit, or Restart

By modifying state variables, the attacker could violate the application’s expectations for the contents of the state, leading to a denial of service due to an unexpected error condition.

 

Potential Mitigations

Phase: Architecture and Design

Description: 

Understand all the potential locations that are accessible to attackers. For example, some programmers assume that cookies and hidden form fields cannot be modified by an attacker, or they may not consider that environment variables can be modified before a privileged program is invoked.

Phase: Architecture and Design

Description: 

Phase: Architecture and Design

Description: 

Store state information on the server side only. Ensure that the system definitively and unambiguously keeps track of its own state and user state and has rules defined for legitimate state transitions. Do not allow any application user to affect state directly in any way other than through legitimate actions leading to state transitions.

Phase: Architecture and Design

Description: 

Phase: Architecture and Design

Description: 

For any security checks that are performed on the client side, ensure that these checks are duplicated on the server side, in order to avoid CWE-602. Attackers can bypass the client-side checks by modifying values after the checks have been performed, or by changing the client to remove the client-side checks entirely. Then, these modified values would be submitted to the server.

Phase: Operation, Implementation

Description: 

When using PHP, configure the application so that it does not use register_globals. During implementation, develop the application so that it does not rely on this feature, but be wary of implementing a register_globals emulation that is subject to weaknesses such as CWE-95, CWE-621, and similar issues.

Phase: Testing

Description: 

Use automated static analysis tools that target this type of weakness. Many modern techniques use data flow analysis to minimize the number of false positives. This is not a perfect solution, since 100% accuracy and coverage are not feasible.

Phase: Testing

Description: 

Use dynamic tools and techniques that interact with the software using large test suites with many diverse inputs, such as fuzz testing (fuzzing), robustness testing, and fault injection. The software’s operation may slow down, but it should not become unstable, crash, or generate incorrect results.

Phase: Testing

Description: 

Use tools and techniques that require manual (human) analysis, such as penetration testing, threat modeling, and interactive tools that allow the tester to record and modify an active session. These may be more effective than strictly automated techniques. This is especially the case with weaknesses that are related to design and business rules.

CVE References

  • CVE-2005-2428
    • Mail client stores password hashes for unrelated accounts in a hidden form field.
  • CVE-2008-0306
    • Privileged program trusts user-specified environment variable to modify critical configuration settings.
  • CVE-1999-0073
    • Telnet daemon allows remote clients to specify critical environment variables for the server, leading to code execution.
  • CVE-2007-4432
    • Untrusted search path vulnerability through modified LD_LIBRARY_PATH environment variable.
  • CVE-2006-7191
    • Untrusted search path vulnerability through modified LD_LIBRARY_PATH environment variable.
  • CVE-2008-5738
    • Calendar application allows bypass of authentication by setting a certain cookie value to 1.
  • CVE-2008-5642
    • Setting of a language preference in a cookie enables path traversal attack.
  • CVE-2008-5125
    • Application allows admin privileges by setting a cookie value to “admin.”
  • CVE-2008-5065
    • Application allows admin privileges by setting a cookie value to “admin.”
  • CVE-2008-4752
    • Application allows admin privileges by setting a cookie value to “admin.”
  • CVE-2000-0102
    • Shopping cart allows price modification via hidden form field.
  • CVE-2000-0253
    • Shopping cart allows price modification via hidden form field.
  • CVE-2008-1319
    • Server allows client to specify the search path, which can be modified to point to a program that the client has uploaded.

CWE-641 – Improper Restriction of Names for Files and Other Resources

Read Time:1 Minute, 30 Second

Description

The application constructs the name of a file or other resource using input from an upstream component, but it does not restrict or incorrectly restricts the resulting name.

This may produce resultant weaknesses. For instance, if the names of these resources contain scripting characters, it is possible that a script may get executed in the client’s browser if the application ever displays the name of the resource on a dynamically generated web page. Alternately, if the resources are consumed by some application parser, a specially crafted name can exploit some vulnerability internal to the parser, potentially resulting in execution of arbitrary code on the server machine. The problems will vary based on the context of usage of such malformed resource names and whether vulnerabilities are present in or assumptions are made by the targeted technology that would make code execution possible.

Modes of Introduction:

– Architecture and Design

 

Likelihood of Exploit: Low

 

Related Weaknesses

CWE-99

 

Consequences

Integrity, Confidentiality, Availability: Execute Unauthorized Code or Commands

Execution of arbitrary code in the context of usage of the resources with dangerous names.

Confidentiality, Availability: Read Application Data, DoS: Crash, Exit, or Restart

Crash of the consumer code of these resources resulting in information leakage or denial of service.

 

Potential Mitigations

Phase: Architecture and Design

Description: 

Do not allow users to control names of resources used on the server side.

Phase: Architecture and Design

Description: 

Perform allowlist input validation at entry points and also before consuming the resources. Reject bad file names rather than trying to cleanse them.

Phase: Architecture and Design

Description: 

Make sure that technologies consuming the resources are not vulnerable (e.g. buffer overflow, format string, etc.) in a way that would allow code execution if the name of the resource is malformed.

CVE References

CWE-640 – Weak Password Recovery Mechanism for Forgotten Password

Read Time:1 Minute, 20 Second

Description

The software contains a mechanism for users to recover or change their passwords without knowing the original password, but the mechanism is weak.

Modes of Introduction:

– Architecture and Design

 

Likelihood of Exploit: High

 

Related Weaknesses

CWE-287
CWE-287

 

Consequences

Access Control: Gain Privileges or Assume Identity

An attacker could gain unauthorized access to the system by retrieving legitimate user’s authentication credentials.

Availability: DoS: Resource Consumption (Other)

An attacker could deny service to legitimate system users by launching a brute force attack on the password recovery mechanism using user ids of legitimate users.

Integrity, Other: Other

The system’s security functionality is turned against the system by the attacker.

 

Potential Mitigations

Phase: Architecture and Design

Description: 

Make sure that all input supplied by the user to the password recovery mechanism is thoroughly filtered and validated.

Phase: Architecture and Design

Description: 

Do not use standard weak security questions and use several security questions.

Phase: Architecture and Design

Description: 

Make sure that there is throttling on the number of incorrect answers to a security question. Disable the password recovery functionality after a certain (small) number of incorrect guesses.

Phase: Architecture and Design

Description: 

Require that the user properly answers the security question prior to resetting their password and sending the new password to the e-mail address of record.

Phase: Architecture and Design

Description: 

Never allow the user to control what e-mail address the new password will be sent to in the password recovery mechanism.

Phase: Architecture and Design

Description: 

Assign a new temporary password rather than revealing the original password.

CVE References

CWE-64 – Windows Shortcut Following (.LNK)

Read Time:1 Minute, 17 Second

Description

The software, when opening a file or directory, does not sufficiently handle when the file is a Windows shortcut (.LNK) whose target is outside of the intended control sphere. This could allow an attacker to cause the software to operate on unauthorized files.

The shortcut (file with the .lnk extension) can permit an attacker to read/write a file that they originally did not have permissions to access.

Modes of Introduction:

– Operation

 

Likelihood of Exploit: Low

 

Related Weaknesses

CWE-59

 

Consequences

Confidentiality, Integrity: Read Files or Directories, Modify Files or Directories

 

Potential Mitigations

Phase: Architecture and Design

Description: 

CVE References

  • CVE-2000-0342
    • Mail client allows remote attackers to bypass the user warning for executable attachments such as .exe, .com, and .bat by using a .lnk file that refers to the attachment, aka “Stealth Attachment.”
  • CVE-2001-1042
    • FTP server allows remote attackers to read arbitrary files and directories by uploading a .lnk (link) file that points to the target file.
  • CVE-2001-1043
    • FTP server allows remote attackers to read arbitrary files and directories by uploading a .lnk (link) file that points to the target file.
  • CVE-2005-0587
    • Browser allows remote malicious web sites to overwrite arbitrary files by tricking the user into downloading a .LNK (link) file twice, which overwrites the file that was referenced in the first .LNK file.
  • CVE-2003-1233
    • Rootkits can bypass file access restrictions to Windows kernel directories using NtCreateSymbolicLinkObject function to create symbolic link

News, Advisories and much more

Exit mobile version