The product stores security-critical state information about its users, or the product itself, in a location that is accessible to unauthorized actors.
If an attacker can modify the state information without detection, then it could be used to perform unauthorized actions or access unexpected resources, since the application programmer does not expect that the state can be changed. State information can be stored in various locations such as a cookie, in a hidden web form field, input parameter or argument, an environment variable, a database record, within a settings file, etc. All of these locations have the potential to be modified by an attacker. When this state information is used to control security or determine resource usage, then it may create a vulnerability. For example, an application may perform authentication, then save the state in an "authenticated=true" cookie. An attacker may simply create this cookie in order to bypass the authentication.
Threat Mapped score: 1.8
Industry: Finiancial
Threat priority: P4 - Informational (Low)
CVE: CVE-2005-2428
Mail client stores password hashes for unrelated accounts in a hidden form field.
CVE: CVE-2008-0306
Privileged program trusts user-specified environment variable to modify critical configuration settings.
CVE: CVE-1999-0073
Telnet daemon allows remote clients to specify critical environment variables for the server, leading to code execution.
CVE: CVE-2007-4432
Untrusted search path vulnerability through modified LD_LIBRARY_PATH environment variable.
CVE: CVE-2006-7191
Untrusted search path vulnerability through modified LD_LIBRARY_PATH environment variable.
CVE: CVE-2008-5738
Calendar application allows bypass of authentication by setting a certain cookie value to 1.
CVE: CVE-2008-5642
Setting of a language preference in a cookie enables path traversal attack.
CVE: CVE-2008-5125
Application allows admin privileges by setting a cookie value to "admin."
CVE: CVE-2008-5065
Application allows admin privileges by setting a cookie value to "admin."
CVE: CVE-2008-4752
Application allows admin privileges by setting a cookie value to "admin."
CVE: CVE-2000-0102
Shopping cart allows price modification via hidden form field.
CVE: CVE-2000-0253
Shopping cart allows price modification via hidden form field.
CVE: 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.
Phase | Note |
---|---|
Architecture and Design | OMISSION: This weakness is caused by missing a security tactic during the architecture and design phase. |
Implementation | N/A |
Intro: In the following example, an authentication flag is read from a browser cookie, thus allowing for external control of user state data.
Cookie[] cookies = request.getCookies(); for (int i =0; i< cookies.length; i++) { Cookie c = cookies[i]; if (c.getName().equals("authenticated") && Boolean.TRUE.equals(c.getValue())) { authenticated = true; } }
Intro: The following code uses input from an HTTP request to create a file name. The programmer has not considered the possibility that an attacker could provide a file name such as "../../tomcat/conf/server.xml", which causes the application to delete one of its own configuration files (CWE-22).
String rName = request.getParameter("reportName"); File rFile = new File("/usr/local/apfr/reports/" + rName); ... rFile.delete();
Intro: The following code uses input from a configuration file to determine which file to open and echo back to the user. If the program runs with privileges and malicious users can change the configuration file, they can use the program to read any file on the system that ends with the extension .txt.
fis = new FileInputStream(cfg.getProperty("sub")+".txt"); amt = fis.read(arr); out.println(arr);
Intro: This program is intended to execute a command that lists the contents of a restricted directory, then performs other actions. Assume that it runs with setuid privileges in order to bypass the permissions check by the operating system.
Body: This code may look harmless at first, since both the directory and the command are set to fixed values that the attacker can't control. The attacker can only see the contents for DIR, which is the intended program behavior. Finally, the programmer is also careful to limit the code that executes with raised privileges.
#define DIR "/restricted/directory" char cmd[500]; sprintf(cmd, "ls -l %480s", DIR); /* Raise privileges to those needed for accessing DIR. */ RaisePrivileges(...); system(cmd); DropPrivileges(...); ...
Intro: The following code segment implements a basic server that uses the "ls" program to perform a directory listing of the directory that is listed in the "HOMEDIR" environment variable. The code intends to allow the user to specify an alternate "LANG" environment variable. This causes "ls" to customize its output based on a given language, which is an important capability when supporting internationalization.
Body: The programmer takes care to call a specific "ls" program and sets the HOMEDIR to a fixed value. However, an attacker can use a command such as "ENV HOMEDIR /secret/directory" to specify an alternate directory, enabling a path traversal attack (CWE-22). At the same time, other attacks are enabled as well, such as OS command injection (CWE-78) by setting HOMEDIR to a value such as "/tmp; rm -rf /". In this case, the programmer never intends for HOMEDIR to be modified, so input validation for HOMEDIR is not the solution. A partial solution would be an allowlist that only allows the LANG variable to be specified in the ENV command. Alternately, assuming this is an authenticated user, the language could be stored in a local file so that no ENV command at all would be needed.
$ENV{"HOMEDIR"} = "/home/mydir/public/"; my $stream = AcceptUntrustedInputStream(); while (<$stream>) { chomp; if (/^ENV ([\w\_]+) (.*)/) { $ENV{$1} = $2; } elsif (/^QUIT/) { ... } elsif (/^LIST/) { open($fh, "/bin/ls -l $ENV{HOMEDIR}|"); while (<$fh>) { SendOutput($stream, "FILEINFO: $_"); } close($fh); } }