CAPEC Detailed Abstraction Attack Pattern Slice Release 1.4
CAPEC Detailed Abstraction Attack Pattern Slice Release 1.4
This view (slice) covers detailed abstraction attack patterns.
| Attack Pattern ID | Pattern Abstraction: Detailed 3 | | Typical Severity | Medium | | Description | Summary An attacker intentionally introduces leading characters that enable getting the input past the filters. The API that is being targetted, ignores the leading "ghost" characters, and therefore processes the attacker's input. This occurs when the targetted API will accept input data in several syntactic forms and interpret it in the equivalent semantic way, while the filter does not take into account the full spectrum of the syntactic forms acceptable to the targetted API.
Some APIs will strip certain leading characters from a string of parameters. Perhaps these characters are considered redundant, and for this reason they are removed. Another possibility is the parser logic at the beginning of analysis is specialized in some way that causes some characters to be removed. The attacker can specify multiple types of alternative encodings at the beginning of a string as a set of probes. One commonly used possibility involves adding ghost characters—extra characters that don't affect the validity of the request at the API layer. If the attacker has access to the API libraries being targeted, certain attack ideas can be tested directly in advance. Once alternative ghost encodings emerge through testing, the attacker can move from lab-based API testing to testing real-world service implementations. Attack Execution Flow Determine if the source code is available and if so, examine the filter logic. If the source code is not available, write a small program that loops through various possible inputs to given API call and tries a variety of alternate (but equivalent) encodings of strings with leading ghost characters. Knowlege of frameworks and libraries used and what filters they apply will help to make this search more structured. Observe the effects. See if the probes are getting past the filters. Identify a string that is semantically equivalent to that which an attacker wants to pass to the targeted API, but syntactically structured in a way as to get past the input filter. That encoding will contain certain ghost characters that will help it get past the filters. These ghost characters will be ignored by the targeted API. Once the "winning" alternate encoding using (typically leading) ghost characters is identified, an attacker can launch the attacks against the targetted API (e.g. directory traversal attack, arbitrarary shell command execution, corruption of files)
| | Attack Prerequisites | The targetted API must ignore the leading ghost characters that are used to get past the filters for the semantics to be the same. | | Typical Likelihood of Exploit |
Medium
| | Methods of Attack | | | Examples-Instances | Description Alternate Encoding with Ghost Characters in FTP and Web Servers
Some web and FTP servers fail to detect prohibited upward directory traversals if the user-supplied pathname contains extra characters such as an extra leading dot. For example, a program that will disallow access to the pathname "../test.txt" may erroneously allow access to that file if the pathname is specified as ".../test.txt". This attack succeeds because 1) the input validation logic fails to detect the triple-dot as a directory traversal attempt (since it isn't dot-dot), 2) some part of the input processing decided to strip off the "extra" dot, leaving the dot-dot behind. Using the file system API as the target, the following strings are all equivalent to many programs: .../../../test.txt ............/../../test.txt ..?/../../test.txt ..????????/../../test.txt ../test.txt As you can see, there are many ways to make a semantically equivalent request. All these strings ultimately result in a request for the file ../test.txt. | | Attacker Skill or Knowledge Required | Medium | | Solutions and Mitigations | Perform white list rather than black list input validation. Canonicalize all data prior to validation. Take an iterative approach to input validation (defense in depth). | | Attack Motivation-Consequences | - Privilege Escalation
- Data Modification
| | Context Description | Building "Equivalent" Requests
A large number of commands are subject to parsing or filtering. In many cases a filter only considers one particular way to format a command. The fact is that the same command can usually be encoded in thousands of different ways. In many cases, an alternative encoding for the command will produce exactly the same results as the original command. Thus, two commands that look different from the logical perspective of a filter end up producing the same semantic result. In many cases, an alternatively encoded command can be used to attack a software system, because the alternative command allows an attacker to perform an operation that would otherwise be blocked. Mapping the API Layer A good approach to help identify and map possible alternate encodings involves writing a small program that loops through all possible inputs to a given API call. This program can, for example, attempt to encode filenames in a variety of ways. For each iteration of the loop, the "mungified" filename can be passed to the API call and the result noted. The following code snippet loops through many possible values that can be used as a prefix to the string \test.txt. Results of running a program like this can help us to determine which characters can be used to perform a ../../ (dots and slashes) relative traversal attack. int main(int argc, char* argv[]) { for(unsigned long c=0x01010101;c != -1;c++) { char _filepath[255]; sprintf(_filepath, "%c%c%c%c\\test.txt", c > 24, c > 16, c > 8, c&0x000000FF ); try { FILE *in_file = fopen(_filepath, "r"); if(in_file) { printf("checking path %s\n", _filepath); puts("file opened!"); getchar(); fclose(in_file); } } catch(...) { } } return 0; } Slight (but still automatic) modifications can be made to the string in creative ways. Ultimately, the modified string boils down to an attempt to use different tricks to obtain the same file. For example, one resulting attempt might try a command like this: sprintf(_filepath, "..%c\\..%c\\..%c\\..%c\\scans2.txt", c, c, c, c); A good way to think about this problem is to think of layers. The API call layer is what the examples shown here are mapping. If an engineer has placed any filters in front of the API call, then these filters can be considered additional layers, wrapping the original set of possibilities. By pondering all the possible inputs that can be provided at the API layer, we can begin uncovering and exercising any filters that the software has in place. If we know that the software definitely uses file API calls, we can try all kinds of filename encoding tricks that we know about. If we get lucky, eventually one set of encoding tricks will work, and we can get our data successfully through the filters and into the API call. Drawing on the techniques described in Chapter 5 of "Exploiting Software: How to Break Code" (See reference - G. Hoglund and G. McGraw) , we can list a number of possible escape codes that can be injected into API calls (many of which help with the filter avoidance problem). If the data are eventually being piped into a shell, for example, we might be able to get control codes to take effect. A particular call may write data to a file or a stream that are eventually meant to be viewed on a terminal or in a client program. As a simple example, the following string contains two backspace characters that are very likely to show up in the terminal's execution: write("echo hey!\x08\x08"); When the terminal interprets the data we have passed in, the output will be missing the last two characters of the original string. This kind of trick has been used for ages to corrupt data in log files. Log files capture all kinds of data about a transaction. It may be possible to insert NULL characters (for example, %00 or '\0') or to add so many extra characters to the string that the request is truncated in the log. Imagine a request that has more than a thousand extra characters tacked on at the end. Ultimately, the string may be trimmed in the log file, and the important telltale data that expose an attack will be lost. Ghost Characters Ghost characters are extra characters that can be added to a request. The extra characters are designed not to affect the validity of the request. One easy example involves adding extra slashes to a filename. In many cases, the strings /some/directory/test.txt and /////////////////some/////////////directory//////////////test.txt are equivalent requests. From G. Hoglund and G. McGraw. Exploiting Software: How to Break Code. Addison-Wesley, February 2004. | | Injection Vector | Web Form, URL, Network Socket, File | | Payload | The payload is the parameter that an attacker is supplying to the targetted API that will allow the attacker to elevate privilege and subvert the authorization service. | | Activation Zone | The targetted API is the activation zone. These attacks often target the file system or the shell to execute commands. | | Payload Activation Impact | Failure in authorization service may lead to compromises in data confidentiality and integrity. | | Related Weaknesses | | CWE-ID | Weakness Name | Weakness Relationship Type |
|---|
| 173 | Failure to Handle Alternate Encoding | Targeted | | 41 | Failure to Resolve Path Equivalence | Targeted | | 172 | Encoding Error | Targeted | | 171 | Cleansing, Canonicalization, and Comparison Errors | Targeted | | 179 | Incorrect Behavior Order: Early Validation | Targeted | | 180 | Incorrect Behavior Order: Validate Before Canonicalize | Targeted | | 181 | Incorrect Behavior Order: Validate Before Filter | Secondary | | 183 | Permissive Whitelist | Secondary | | 184 | Incomplete Blacklist | Secondary | | 20 | Improper Input Validation | Targeted | | 74 | Failure to Sanitize Data into a Different Plane (aka 'Injection') | Targeted | | 697 | Insufficient Comparison | Targeted | | 707 | Failure to Enforce that Messages or Data are Well-Formed | Targeted |
| | Related Security Principles | - Defense in Depth
- Reluctance to Trust
- Least Privilege
| | Related Guidelines | - Perform input validation and filtering on data in its canonical form.
- Understand the APIs to which user input will be passed and know how permissive they are. Perform appropriate input validation given that information.
| | Purpose | Exploitation | | CIA Impact | | Confidentiality Impact | Integrity Impact | Availability Impact |
|---|
| Low | Low | High |
| | Technical Context | | Architectural Paradigm | Framework | Platform | Language |
|---|
| All | All | All | All |
| | References | G. Hoglund and G. McGraw. Exploiting Software: How to Break Code. Addison-Wesley, February 2004. | | Source | | Submission(s) |
|---|
| Submitter | Organization | Date | Comment |
|---|
| G. Hoglund and G. McGraw. Exploiting Software: How to Break Code. Addison-Wesley, February 2004. | Cigital, Inc | 2007-03-01 | |
| Modification(s) |
|---|
| Modifier | Organization | Date | Comment |
|---|
| Eugene Lebanidze | Cigital, Inc | 2007-02-26 | Fleshed out content to CAPEC schema from the original descriptions in "Exploiting Software" | | Sean Barnum | Cigital, Inc | 2007-03-05 | Review and revise | | Richard Struse | VOXEM, Inc | 2007-03-26 | Review and feedback leading to changes in Name, Attack Execution Flow and Examples | | Sean Barnum | Cigital, Inc | 2007-04-13 | Modified pattern content according to review and feedback |
|
| Attack Pattern ID | Pattern Abstraction: Detailed 4 | | Typical Severity | High | | Description | Summary This attack relies on the attacker using unexpected formats for representing IP addresses. Networked applications may expect network location information in a specific format, such as fully qualified domains names, URL, IP address, or IP Address ranges. The issue that the attacker can exploit is that these design assumptions may not be validated against a variety of different possible encodings and network address location formats. Applications that use naming for creating policy namespaces for managing access control may be susceptible to queryin directly by IP addresses, which is ultimately a more generally authoritative way of communicating on a network. Alternative IP addresses can be used by the attacker to bypass application access control in order to gain access to data that is only protected by obscuring its location. In addition this type of attack can be used as a reconnaissance mechansim to provide entry point information that the attacker gathers to penetrate deeper into the system. | | Attack Prerequisites | The target software must fail to anticipate all of the possible valid encodings of an IP/web address. | | Typical Likelihood of Exploit |
Medium
| | Methods of Attack | - Injection
- Protocol Manipulation
- API Abuse
| | Examples-Instances | Description An attacker identifies an application server that applies a security policy based on the domain and application name, so the access control policy covers authentication and authorization for anyone accessing http://example.domain:8080/application. However, by putting in the IP address of the host the application authentication and authorization controls may be bypassed http://192.168.0.1:8080/application. The attacker relies on the victim applying policy to the namespace abstraction and not having a default deny policy in place to manage exceptions. | | Attacker Skill or Knowledge Required | Low: The attacker has only to try IP address combinations. | | Resources Required | Ability to communicate with server. Optionally, ability to capture output directly through synchronous communication or other method such as FTP. | | Solutions and Mitigations | Design: Default deny access control policies Design: Input validation routines should check and enforce both input data types and content against a positive specification. In regards to IP addresses, this should include the authorized manner for the application to represent IP addresses and not accept user specified IP addresses and IP address formats (such as ranges) Implementation: Perform input validation for all remote content. | | Attack Motivation-Consequences | | | Context Description | "Attack Pattern: Alternative IP Addresses "IP address ranges can be represented using alternative methods. Here are some examples: 192.168.0.0/24 192.168.0.0/255.255.255.0 192.168.0.* Classic encoding techniques can be directed against IP numbers as well." [Hoglund and McGraw 04] | | Injection Vector | Malicious input delivered through standard input | | Payload | Varies with instantiation of attack pattern. Malicious payload may be passed directly from appliation client, such as the web browser. | | Activation Zone | Client machine and client network | | Payload Activation Impact | Enables attacker to view and access unexpected network services. | | Related Weaknesses | | CWE-ID | Weakness Name | Weakness Relationship Type |
|---|
| 291 | Trusting Self-reported IP Address | Targeted | | 180 | Incorrect Behavior Order: Validate Before Canonicalize | Targeted | | 41 | Failure to Resolve Path Equivalence | Targeted | | 345 | Insufficient Verification of Data Authenticity | Targeted | | 697 | Insufficient Comparison | Targeted | | 707 | Failure to Enforce that Messages or Data are Well-Formed | Targeted |
| | Purpose | Penetration | | CIA Impact | | Confidentiality Impact | Integrity Impact | Availability Impact |
|---|
| Medium | Medium | High |
| | Technical Context | | Architectural Paradigm | Framework | Platform | Language |
|---|
| All | All | All | All |
| | References | G. Hoglund and G. McGraw. Exploiting Software: How to Break Code. Addison-Wesley, February 2004. | | Source | | Submission(s) |
|---|
| Submitter | Organization | Date | Comment |
|---|
| G. Hoglund and G. McGraw. Exploiting Software: How to Break Code. Addison-Wesley, February 2004. | Cigital, Inc | 2007-01-01 | |
| Modification(s) |
|---|
| Modifier | Organization | Date | Comment |
|---|
| Gunnar Peterson | Cigital, Inc | 2007-02-28 | Fleshed out content to CAPEC schema from the original descriptions in "Exploiting Software" | | Sean Barnum | Cigital, Inc | 2007-03-09 | Review and revise | | Richard Struse | VOXEM, Inc | 2007-03-26 | Review and feedback leading to changes in Name, Attack Prerequisites,Resources Required and Method of Attack | | Sean Barnum | Cigital, Inc | 2007-04-13 | Modified pattern content according to review and feedback |
|
| Attack Pattern ID | Pattern Abstraction: Detailed 5 | | Typical Severity | Very High | | Description | Summary This attack against older telephone switches and trunks has been around for decades. The signal is sent by the attacker to impersonate a supervisor signal. This has the effect of rerouting or usurping command of the line and call. While the US infrastructure proper may not contain widespread vulnerabilities to this type of attack, many companies are connected globally through call centers and business process outsourcing. These international systems may be operated in countries which have not upgraded telco infrastructure and so are vulnerable to Blue boxing.
Blue boxing is a result of failure on the part of the system to enforce strong authentication for administrative functions. While the infrastructure is different than standard current applications like web applications, there are hisotrical lessons to be learned to upgrade the access control for administrative functions. | | Attack Prerequisites | System must use weak authentication mechanisms for administrative functions. | | Typical Likelihood of Exploit |
Medium
| | Methods of Attack | - Injection
- Protocol Manipulation
| | Examples-Instances | Description Attacker identifies a vulnerable CCITT-5 phone line, and sends a combination tone to the switch in order to request administrative access. Based on tone and timing parameters the request is verified for access to the switch. Once the attacker has gained control of the switch launching calls, routing calls, and a whole host of opportunities are available. | | Attacker Skill or Knowledge Required | Low: Given a vulnerable phone system, the attacker's technical vector relies on attacks that are well documented in cracker 'zines and have been around for decades. | | Resources Required | CCITT-5 or other vulnerable lines, with the ability to send tones such as combined 2,400 Hz and 2,600 Hz tones to the switch | | Solutions and Mitigations | Implementation: Upgrade phone lines. Note this may be prohibitively expensive Use strong access control such as two factor access control for adminsitrative access to the switch | | Attack Motivation-Consequences | - Denial of Service
- Privilege Escalation
| | Context Description | "Attack Pattern: Analog In-band Switching Signals (aka "Blue Boxing") Many people have heard of 2600, the frequency used in the United States to control telephone switches during the 1960s and 1970s. (Come to think of it, probably more people have heard of the hacker 'zine 2600 and its associated club than have heard of the reason for the name of the club,) Most systems are no longer vulnerable to ancient phreaking attacks. However older systems are still found internationally. Overseas trunk lines that use trans-Atlantic cabling are prone to the in-band signal problem, and they are too expensive a resource to abandon. Thus, many overseas (home-country direct) 800/888 numbers are known to have in-band signal problems even today.
Consider the CCITT-5(C5) signaling system that is used internationally. This system does not use the commonly known 2,600 Hz, but instead uses 2,400Hz as a control signal. If you have ever heard the "pleeps" and chirps on the Pink Floyd album "The Wall," then you have heard C5 signals. There are millions of phone lines still in operation today that are routed through switches with in-band signaling.
This attack pattern involves playing specific control commands across a normal voice link, thus seizing control of the line, rerouting calls, and so on."
[Hoglund and McGraw 04] | | Injection Vector | Payload delivered through standard communication protocols. | | Payload | Command(s) executed directly on host | | Activation Zone | Client machine and client network | | Payload Activation Impact | Enables calls to be rerouted. | | Related Weaknesses | | CWE-ID | Weakness Name | Weakness Relationship Type |
|---|
| 264 | Permissions, Privileges, and Access Controls | Targeted |
| | Purpose | Penetration | | CIA Impact | | Confidentiality Impact | Integrity Impact | Availability Impact |
|---|
| Low | Medium | Medium |
| | Technical Context | | Architectural Paradigm | Framework | Platform | Language |
|---|
| Other | Other | Other | All |
| | References | G. Hoglund and G. McGraw. Exploiting Software: How to Break Code. Addison-Wesley, February 2004. | | Source | | Submission(s) |
|---|
| Submitter | Organization | Date | Comment |
|---|
| G. Hoglund and G. McGraw. Exploiting Software: How to Break Code. Addison-Wesley, February 2004. | Cigital, Inc | 2007-01-01 | |
| Modification(s) |
|---|
| Modifier | Organization | Date | Comment |
|---|
| Gunnar Peterson | Cigital, Inc | 2007-02-28 | Fleshed out content to CAPEC schema from the original descriptions in "Exploiting Software" | | Sean Barnum | Cigital, Inc | 2007-03-09 | Review and revise |
|
| Attack Pattern ID | Pattern Abstraction: Detailed 7 | | Typical Severity | High | | Description | Summary Blind SQL Injection results from an insufficient mitigation for SQL Injection. Although suppressing database error messages are considered best practice, the suppression alone is not sufficient to prevent SQL Injection. Blind SQL Injection is a form of SQL Injection that overcomes the lack of error messages. Without the error messages that facilitate SQL Injection, the attacker constructs input strings that probe the target through simple Boolean SQL expressions. The attacker can determine if the syntax and structure of the injection was successful based on whether the query was executed or not. Applied iteratively, the attacker determines how and where the target is vulnerable to SQL Injection. For example, an attacker may try entering something like "username' AND 1=1; --" in an input field. If the result is the same as when the attacker entered "username" in the field, then the attacker knows that the application is vulnerable to SQL Injection. The attacker can then ask yes/no questions from the database server to extract information from it. For example, the attacker can extract table names from a database using the following types of queries: "username' AND ascii(lower(substring((SELECT TOP 1 name FROM sysobjects WHERE xtype='U'), 1, 1))) > 108". If the above query executes properly, then the attacker knows that the first character in a table name in the database is a letter between m and z. If it doesn't, then the attacker knows that the character must be between a and l (assuming of course that table names only contain alphabetic characters). By performing a binary search on all character positions, the attacker can determine all table names in the database. Subsequently, the attacker may execute an actual attack and send something like: "username'; DROP TABLE trades; -- Attack Execution Flow Explore Hypothesize SQL queries in application: Generated hypotheses regarding the SQL queries in an application. For example, the attacker may hypothesize that his input is passed directly into a query that looks like:
"SELECT * FROM orders WHERE ordernum = _____"
or
"SELECT * FROM orders WHERE ordernum IN (_____)"
or
"SELECT * FROM orders WHERE ordernum in (_____) ORDER BY _____"
Of course, there are many other possibilities. | Attack Step
Technique |
|---|
| Description | Environments |
|---|
| Research types of SQL queries and determine which ones could be used at various places in an application. | env-All |
Determine how to inject information into the queries: Determine how to inject information into the queries from the previous step such that the injection does not impact their logic. For example, the following are possible injections for those queries:
"5' OR 1=1; --"
and
"5) OR 1=1; --"
and
"ordernum DESC; --" | Attack Step
Techniques |
|---|
| Description | Environments |
|---|
| Add clauses to the SQL queries such that the query logic does not change. | env-All | | Add delays to the SQL queries in case server does not provide clear error messages (e.g. WAITFOR DELAY '0:0:10' in SQL Server or BENCHMARK(1000000000,MD5(1) in MySQL). If these can be injected into the queries, then the length of time that the server takes to respond reveals whether the query is injectable or not. | env-All |
| Outcome |
|---|
| ID | Type | Description |
|---|
| c7s2o1 | Success | At least one way to complete a hypothesized SQL query that would violate the application developer's assumptions. |
Experiment Determine user-controllable input susceptible to injection: Determine the user-controllable input susceptible to injection. For each user-controllable input that the attacker suspects is vulnerable to SQL injection, attempt to inject the values determined in the previous step. If an error does not occur, then the attacker knows that the SQL injection was successful. | Attack Step
Techniques |
|---|
| Description | Environments |
|---|
| Use web browser to inject input through text fields or through HTTP GET parameters. | env-Web | | Use a web application debugging tool such as Tamper Data, TamperIE, WebScarab,etc. to modify HTTP POST parameters, hidden fields, non-freeform fields, etc. | env-Web | | Use network-level packet injection tools such as netcat to inject input | env-Web env-ClientServer env-Peer2Peer env-CommProtocol | | Use modified client (modified by reverse engineering) to inject input. | env-ClientServer env-Peer2Peer env-CommProtocol |
| Indicators of
Susceptibility |
|---|
| ID | Type | Description | Environments |
|---|
| c7s3i1 | Positive | Attacker receives normal response from server. | env-Web env-ClientServer env-Peer2Peer env-CommProtocol | | c7s3i2 | Positive | Response takes expected amount of time after delay is injected. | env-Web env-ClientServer env-Peer2Peer env-CommProtocol | | c7s3i3 | Negative | Server sends a specific error message that indicates programmatic parsing of the input data (e.g. NumberFormatException) | env-Web env-ClientServer env-Peer2Peer env-CommProtocol |
| Outcomes |
|---|
| ID | Type | Description |
|---|
| c7s3o1 | Success | At least one user-controllable input susceptible to injection found. | | c7s3o2 | Failure | No user-controllable input susceptible to injection found. |
| Security
Controls |
|---|
| ID | Type | Description |
|---|
| c7s3sc1 | Detective | Unusual queries such as the ones described in the previous step, in application logs. Log files may contain unusual messages such as "User bob' OR 1=1; -- logged in". Operators should be alerted when such SQL commands appear in the logs. | | c7s3sc2 | Preventative | Input validation of user-controlled data before including it in a SQL query | | c7s3sc3 | Preventative | Use APIs that help mitigate SQL injection (such as PreparedStatement in Java) |
Determine database type: Determines the type of the database, such as MS SQL Server or Oracle or MySQL, using logical conditions as part of the injected queries | Attack Step
Techniques |
|---|
| Description | Environments |
|---|
| Try injecting a string containing char(0x31)=char(0x31) (this evaluates to 1=1 in SQL Server only) | env-Web env-ClientServer env-Peer2Peer env-CommProtocol | | Try injecting a string containing 0x313D31 (this evaluates to 1=1 in MySQL only) | env-Web env-ClientServer env-Peer2Peer env-CommProtocol | | Inject other database-specific commands into input fields susceptible to SQL Injection. The attacker can determine the type of database that is running by checking whether the query executed successfully or not (i.e. wheter the attacker received a normal response from the server or not). | env-Web env-ClientServer env-Peer2Peer env-CommProtocol |
| Indicators of
Susceptibility |
|---|
| ID | Type | Description | Environments |
|---|
| c7s4i1 | Positive | Success outcome in previous step | env-Web env-ClientServer env-Peer2Peer env-CommProtocol | | c7s4i2 | Negative | Failure outcome in previous step | env-Web env-ClientServer env-Peer2Peer env-CommProtocol |
| Outcomes |
|---|
| ID | Type | Description |
|---|
| c7s4o1 | Success | Database platform in use discovered. | | c7s4o2 | Failure | Database platform in use not discovered. |
Exploit Extract information about database schema: Extract information about database schema by getting the database to answer yes/no questions about the schema. | Attack Step
Techniques |
|---|
| Description | Environments |
|---|
| Automatically extract database schema using a tool such as Absinthe. | env-Web | | Manually perform the blind SQL Injection to extract desired information about the database schema. | env-Web env-ClientServer env-Peer2Peer env-CommProtocol |
| Indicators of
Susceptibility |
|---|
| ID | Type | Description | Environments |
|---|
| c7s5i1 | Positive | Success outcome in previous step. | env-Web env-ClientServer env-Peer2Peer env-CommProtocol | | c7s5i2 | Negative | Failure outcome in previous step. | env-Web env-ClientServer env-Peer2Peer env-CommProtocol |
| Outcomes |
|---|
| ID | Type | Description |
|---|
| c7s5o1 | Success | Desired information about database schema extracted. | | c7s5o2 | Failure | Desired information about database schema could not be extracted. |
| Security
Control |
|---|
| ID | Type | Description |
|---|
| c7s5sc1 | Detective | Large number of unusual queries in database logs. |
Exploit SQL Injection vulnerability: Use the information obtained in the previous steps to successfully inject the database in order to bypass checks or modify, add, retrieve or delete data from the database | Attack Step
Technique |
|---|
| Description | Environments |
|---|
| Use information about how to inject commands into SQL queries as well as information about the database schema to execute attacks such as dropping tables, inserting records, etc. | env-Web env-ClientServer env-Peer2Peer env-CommProtocol |
| Indicators of
Susceptibility |
|---|
| ID | Type | Description | Environments |
|---|
| c7s6i1 | Positive | Success outcome in previous step. | env-Web env-ClientServer env-Peer2Peer env-CommProtocol | | c7s6i2 | Negative | Failure outcome in previous step. | env-Web env-ClientServer env-Peer2Peer env-CommProtocol |
| Outcomes |
|---|
| ID | Type | Description |
|---|
| c7s6o1 | Success | Attacker achieves goal of unauthorized system access, denial of service, etc. | | c7s6o2 | Failure | Attacker cannot exploit the information gathered by blind SQL Injection |
| | Attack Prerequisites | SQL queries used by the application to store, retrieve or modify data. User-controllable input that is not properly validated by the application as part of SQL queries. | | Typical Likelihood of Exploit |
High
| | Methods of Attack | | | Examples-Instances | Description In the PHP application TimeSheet 1.1, an attacker can successfully retrieve username and password hashes from the database using Blind SQL Injection. If the attacker is aware of the local path structure, the attacker can also remotely execute arbitrary code and write the output of the injected queries to the local path. Blind SQL Injection is possible since the application does not properly sanitize the $_POST['username'] variable in the login.php file. Related Vulnerability | | Attacker Skill or Knowledge Required | Medium - Determining the database type and version, as well as the right number and type of parameters to the query being injected in the absence of error messages requires greater skill than reverse-engineering database error messages. | | Resources Required | None | | Probing Techniques | In order to determine the right syntax for the query to inject, the attacker tries to determine the right number of parameters to the query and their types. This is achieved by formulating conditions that result in a true/false answer from the database. If the logical condition is true, the database will execute the rest of the query. If not, a custom error page or a default page is returned. Another approach is to ask such true/false questions of the database and note the response times to a query with a logically true condition and one with a false condition. | | Indicators-Warnings of Attack | The only indicators of successful Blind SQL Injection are the application or database logs that show similar queries with slightly differing logical conditions that increase in complexity over time. However, this requires extensive logging as well as knowledge of the queries that can be used to perform such injection and return meaningful information from the database. | | Solutions and Mitigations | Security by Obscurity is not a solution to preventing SQL Injection. Rather than suppress error messages and exceptions, the application must handle them gracefully, returning either a custom error page or redirecting the user to a default page, without revealing any information about the database or the application internals. Strong input validation - All user-controllable input must be validated and filtered for illegal characters as well as SQL content. Keywords such as UNION, SELECT or INSERT must be filtered in addition to characters such as a single-quote(') or SQL-comments (--) based on the context in which they appear. | | Attack Motivation-Consequences | - Data Modification
- Information Leakage
- Run Arbitrary Code
| | Context Description | An attacker attempts Blind SQL Injection when traditional SQL Injection is not possible due to suppression of error messages. Blind SQL Injection is performed by appending logical conditions to the query being injected such that they evaluate to true or false in the context of the data stored in the database. The first step is to get the syntax for the injected query right. For example, consider a database that has a table named "users". Consider the following query: SELECT fname, lname, dob, ssn, address FROM users WHERE userid="user1" AND password="user1pwd"; To determine whether the "userid" field is injectable or not, the attacker tries an input such as user1" AND 3>1+1;-- This causes the following query SELECT fname, lname, dob, ssn, address FROM users WHERE userid="user1" AND 3>1+1;-- to be passed to the database. If the parameter is injectable, the database evaluates 3>1+1 to be true and executes the query. If, on the other hand, a condition such as 3<2 were passed, the database would return an error. Since the application suppresses such errors, the attacker never sees it. However, the application may simply hang or it may redirect to a custom error page or a default page, which is definitely an indication that the injected condition was evaluated to be false. The query can also fail if the original condition was within parentheses, such as WHERE (userid="johns" AND password="abracadabra") In such a case, the attacker will have to try injection such that the parentheses match up. Once the attacker gets the syntax right, the next step is to identify the database. This can be achieved by using operators that are unique to each database engine. For example, a condition such as "abc" = "a"+"bc" evaluates to true on MS SQL Server whereas it evaluates to false on Oracle since the concatentation operator is ||. Another approach is using system-specific functions such as those for date and time. The next step is to determine the number and type of parameters. This can again be achieved by exploiting the SELECT...WHERE conditions or using UNION SELECT statements with dummy numeric or character-based parameters. Once the type of database as well as the structure of the query has been mapped out by asking a number of questions to the database, the attacker is in a position to inject the database and extract information from it. Blind SQL Injection is a classic example of solution by reduction where the domain to be attacked is successively narrowed down by the attacker through true or false queries to the database. | | Injection Vector | User-controllable input to the application | | Payload | SQL statements intended to bypass checks or retrieve information about the database | | Activation Zone | Back-end database | | Payload Activation Impact | The injected SQL statements are such that they result in a true/false query to the database. If the database evaluates a statement to be logically true, it responds with the requested data. If the condition is evaluated to be logically false, an error is returned. The attacker modifies the boolean condition each time to gain information from the database. | | Related Weaknesses | | CWE-ID | Weakness Name | Weakness Relationship Type |
|---|
| 89 | Failure to Preserve SQL Query Structure (aka 'SQL Injection') | Targeted | | 209 | Error Message Information Leak | Targeted | | 74 | Failure to Sanitize Data into a Different Plane (aka 'Injection') | Secondary | | 20 | Improper Input Validation | Secondary | | 390 | Detection of Error Condition Without Action | Secondary | | 697 | Insufficient Comparison | Secondary | | 713 | OWASP Top Ten 2007 Category A2 - Injection Flaws | Secondary | | 707 | Failure to Enforce that Messages or Data are Well-Formed | Secondary |
| | Related Attack Patterns | | ID | Name | Relationship Type | Relationship Description |
|---|
| 66 | SQL Injection | Occasionally Precedes | |
| | Relevant Security Requirements | Custom error pages must be used to handle exceptions such that they do not reveal any information about the architecture of the application or the database. Special characters in user-controllable input must be escaped before use by the application. Employ application-level safeguards to filter data and handle exceptions gracefully. | | Related Security Principles | - Reluctance to Trust
- Failing Securely
- Defense in Depth
| | Related Guidelines | - Never Use Input as Part of a Directive to any Internal Component
- Handle All Errors Safely
| | Purpose | Penetration | | CIA Impact | | Confidentiality Impact | Integrity Impact | Availability Impact |
|---|
| High | High | High |
| | Technical Context | | Architectural Paradigm | Framework | Platform | Language |
|---|
| All | All | All | All |
| | References | CWE - Input Validation CWE - Improper Error Handling | | Source | | Submission(s) |
|---|
| Submitter | Organization | Date | Comment |
|---|
| Chiradeep B Chhaya | | 2007-02-22 | Third Draft - Revised to schema v1.4 |
| Modification(s) |
|---|
| Modifier | Organization | Date | Comment |
|---|
| Malik Hamro | Cigital, Inc | 2007-02-27 | Reformat to new schema and review | | Sean Barnum | Cigital, Inc | 2007-03-05 | Review and revise | | Richard Struse | VOXEM, Inc | 2007-03-26 | Review and feedback leading to changes in Description, Attack Prerequisites and Related Attack Patterns | | Sean Barnum | Cigital, Inc | 2007-04-13 | Modified pattern content according to review and feedback | | Amit Sethi | Cigital, Inc. | 2007-10-29 | Added extended Attack Execution Flow |
|
| Attack Pattern ID | Pattern Abstraction: Detailed 8 | | Typical Severity | High | | Description | Summary This attack targets libraries or shared code modules which are vulnerable to buffer overflow attacks. An attacker who has access to an API may try to embed malicious code in the API function call and exploit a buffer overflow vulnerability in the function's implementation. All clients that make use of the code library thus become vulnerable by association. This has a very broad effect on security across a system, usually affecting more than one software process. Attack Execution Flow An attacker can call an API exposed by the target host. On the probing stage, the attacker injects malicious code using the API call and observes the results. The attacker's goal is to uncover a buffer overflow vulnerability. The attacker finds a buffer overflow vulnerability, crafts malicious code and injects it through an API call. The attacker can at worst execute remote code on the target host.
| | Attack Prerequisites | The target host exposes an API to the user. One or more API functions exposed by the target host has a buffer overflow vulnerability. | | Typical Likelihood of Exploit |
High
| | Methods of Attack | | | Examples-Instances | Description Attack Example: Libc in FreeBSD
A buffer overflow in the FreeBSD utility setlocale (found in the libc module) puts many programs at risk all at once. Description Xtlib
A buffer overflow in the Xt library of the X windowing system allows local users to execute commands with root privileges. | | Attacker Skill or Knowledge Required | Low : An attacker can simply overflow a buffer by inserting a long string into an attacker-modifiable injection vector. The result can be a DoS. High : Exploiting a buffer overflow to inject malicious code into the stack of a software system or even the heap can require a higher skill level. | | Solutions and Mitigations | Use a language or compiler that performs automatic bounds checking. Use secure functions not vulnerable to buffer overflow. If you have to use dangerous functions, make sure that you do boundary checking. Compiler-based canary mechanisms such as StackGuard, ProPolice and the Microsoft Visual Studio /GS flag. Unless this provides automatic bounds checking, it is not a complete solution. Use OS-level preventative functionality. Not a complete solution. | | Attack Motivation-Consequences | - Denial of Service
- Run Arbitrary Code
- Information Leakage
- Data Modification
| | Injection Vector | The user supplied data. | | Payload | The buffer overrun by the attacker. | | Activation Zone | When the function returns control to the main program, it jumps to the return address portion of the stack frame. Unfortunately that return address may have been overwritten by the overflowed buffer and the address may contain a call to a privileged command or to a malicious code. | | Payload Activation Impact | The most common is remote code execution. | | Related Weaknesses | | CWE-ID | Weakness Name | Weakness Relationship Type |
|---|
| 120 | Buffer Copy without Checking Size of Input ('Classic Buffer Overflow') | Targeted | | 119 | Failure to Constrain Operations within the Bounds of a Memory Buffer | Targeted | | 118 | Improper Access of Indexable Resource (aka 'Range Error') | Targeted | | 74 | Failure to Sanitize Data into a Different Plane (aka 'Injection') | Targeted | | 20 | Improper Input Validation | Targeted | | 680 | Integer Overflow to Buffer Overflow | Targeted | | 733 | Compiler Optimization Removal or Modification of Security-critical Code | Secondary | | 697 | Insufficient Comparison | Targeted |
| | Related Attack Patterns | | ID | Name | Relationship Type | Relationship Description |
|---|
| 100 | Overflow Buffers | More Detailed | |
| | Relevant Security Requirements | Bound checking should be performed when copying data to a buffer. | | Related Security Principles | - Reluctance to trust
- Defense in Depth
| | Purpose | Penetration | | CIA Impact | | Confidentiality Impact | Integrity Impact | Availability Impact |
|---|
| High | High | High |
| | Technical Context | | Architectural Paradigm | Framework | Platform | Language |
|---|
| All | All | All | All |
| | References | G. Hoglund and G. McGraw. Exploiting Software: How to Break Code. Addison-Wesley, February 2004. CWE - Buffer Errors | | Source | | Submission(s) |
|---|
| Submitter | Organization | Date | Comment |
|---|
| G. Hoglund and G. McGraw. Exploiting Software: How to Break Code. Addison-Wesley, February 2004. | Cigital, Inc | 2007-03-01 | |
| Modification(s) |
|---|
| Modifier | Organization | Date | Comment |
|---|
| Eric Dalci | Cigital, Inc | 2007-02-13 | Fleshed out content to CAPEC schema from the original descriptions in "Exploiting Software" | | Sean Barnum | Cigital, Inc | 2007-03-05 | Review and revise | | Richard Struse | VOXEM, Inc | 2007-03-26 | Review and feedback leading to changes in Description | | Sean Barnum | Cigital, Inc | 2007-04-13 | Modified pattern content according to review and feedback |
|
| Attack Pattern ID | Pattern Abstraction: Detailed 9 | | Typical Severity | High | | Description | Summary This attack targets command-line utilities available in a number of shells. An attacker can leverage a vulnerability found in a command-line utility to escalate privilege to root. Attack Execution Flow Attacker identifies command utilities exposed by the target host. On the probing stage, the attacker interacts with the command utility and observes the results of its input. The attacker's goal is to uncover a buffer oveflow in the command utility. For instance the attacker may find that input data are not properly validated. The attacker finds a buffer overflow vulnerability in the command utility and tries to exploit it. He crafts malicious code and injects it using the command utility. The attacker can at worst execute remote code on the target host.
| | Attack Prerequisites | The target host exposes a command-line utility to the user. The command-line utility exposed by the target host has a buffer overflow vulnerability that can be exploited. | | Typical Likelihood of Exploit |
High
| | Methods of Attack | | | Examples-Instances | Description Attack Example: HPUX passwd
A buffer overflow in the HPUX passwd command allows local users to gain root privileges via a command-line option. Attack Example: Solaris getopt A buffer overflow in Solaris's getopt command (found in libc) allows local users to gain root privileges via a long argv[0]. | | Attacker Skill or Knowledge Required | Low : An attacker can simply overflow a buffer by inserting a long string into an attacker-modifiable injection vector. The result can be a DoS. High : Exploiting a buffer overflow to inject malicious code into the stack of a software system or even the heap can require a higher skill level. | | Probing Techniques | The attacker can probe for services available on the target host. Many services may expose a command utility. For instance Telnet is a service which can be invoked through a command shell. | | Solutions and Mitigations | Carefully review the service's implementation before making it available to user. For instance you can use manual or automated code review to uncover vulnerabilities such as buffer overflow. Use a language or compiler that performs automatic bounds checking. Use an abstraction library to abstract away risky APIs. Not a complete solution. Compiler-based canary mechanisms such as StackGuard, ProPolice and the Microsoft Visual Studio /GS flag. Unless this provides automatic bounds checking, it is not a complete solution. Operational: Use OS-level preventative functionality. Not a complete solution. Apply the latest patches to your user exposed services. This may not be a complete solution, specially against zero day attack. Do not unnecessarily expose services. | | Attack Motivation-Consequences | - Privilege Escalation
- Run Arbitrary Code
- Data Modification
- Denial of Service
- Information Leakage
| | Injection Vector | The user supplied data. | | Payload | The buffer overrun by the attacker. | | Activation Zone | When the function returns control to the main program, it jumps to the return address portion of the stack frame. Unfortunately that return address may have been overwritten by the overflowed buffer and the address may contain a call to a privileged command or to a malicious code. | | Payload Activation Impact | The most common is remote code execution. | | Related Weaknesses | | CWE-ID | Weakness Name | Weakness Relationship Type |
|---|
| 120 | Buffer Copy without Checking Size of Input ('Classic Buffer Overflow') | Targeted | | 118 | Improper Access of Indexable Resource (aka 'Range Error') | Targeted | | 119 | Failure to Constrain Operations within the Bounds of a Memory Buffer | Targeted | | 74 | Failure to Sanitize Data into a Different Plane (aka 'Injection') | Targeted | | 20 | Improper Input Validation | Targeted | | 680 | Integer Overflow to Buffer Overflow | Targeted | | 733 | Compiler Optimization Removal or Modification of Security-critical Code | Secondary | | 697 | Insufficient Comparison | Targeted |
| | Related Attack Patterns | | ID | Name | Relationship Type | Relationship Description |
|---|
| 100 | Overflow Buffers | More Detailed | | | 10 | Buffer Overflow via Environment Variables | More Detailed | |
| | Related Security Principles | - Reluctance to trust
- Defense in Depth
- Least Privilege
| | Related Guidelines | - Bound checking should be performed when copying data to a buffer.
| | Purpose | Penetration | | CIA Impact | | Confidentiality Impact | Integrity Impact | Availability Impact |
|---|
| High | High | High |
| | Technical Context | | Architectural Paradigm | Framework | Platform | Language |
|---|
| All | All | All | All |
| | References | G. Hoglund and G. McGraw. Exploiting Software: How to Break Code. Addison-Wesley, February 2004. CWE - Buffer Errors | | Source | | Submission(s) |
|---|
| Submitter | Organization | Date | Comment |
|---|
| G. Hoglund and G. McGraw. Exploiting Software: How to Break Code. Addison-Wesley, February 2004. | Cigital, Inc | 2007-03-01 | |
| Modification(s) |
|---|
| Modifier | Organization | Date | Comment |
|---|
| Eric Dalci | Cigital, Inc | 2007-02-13 | Fleshed out content to CAPEC schema from the original descriptions in "Exploiting Software" | | Sean Barnum | Cigital, Inc | 2007-03-05 | Review and revise | | Richard Struse | VOXEM, Inc | 2007-03-26 | Review and feedback leading to changes in Attack Execution Flow, Probing Techniques and Method of Attack | | Sean Barnum | Cigital, Inc | 2007-04-13 | Modified pattern content according to review and feedback |
|
| Attack Pattern ID | Pattern Abstraction: Detailed 10 | | Typical Severity | High | | Description | Summary This attack pattern involves causing a buffer overflow through manipulation of environment variables. Once the attacker finds that they can modify an environment variable, they may try to overflow associated buffers. This attack leverages implicit trust often placed in environment variables. Attack Execution Flow The attacker tries to find an environment variable which can be overwritten for instance by gathering information about the target host (error pages, software's version number, etc.). The attacker manipulates the environment variable to contain excessive-length content to cause a buffer overflow. The attacker potentially leverages the buffer overflow to inject maliciously crafted code in an attempt to execute privileged command on the target environment.
| | Attack Prerequisites | The application uses environment variables. An environment variable exposed to the user is vulnerable to a buffer overflow. The vulnerable environment variable uses untrusted data. Tainted data used in the environment variables is not properly validated. For instance boundary checking is not done before copying the input data to a buffer. | | Typical Likelihood of Exploit |
High
| | Methods of Attack | | | Examples-Instances | Description Attack Example: Buffer Overflow in $HOME
A buffer overflow in sccw allows local users to gain root access via the $HOME environmental variable. Related Vulnerability Description Attack Example: Buffer Overflow in TERM
A buffer overflow in the rlogin program involves its consumption of the TERM environmental variable. Related Vulnerability | | Attacker Skill or Knowledge Required | Low : An attacker can simply overflow a buffer by inserting a long string into an attacker-modifiable injection vector. The result can be a DoS. High : Exploiting a buffer overflow to inject malicious code into the stack of a software system or even the heap can require a higher skill level. | | Probing Techniques | While interacting with a system an attacker would typically investigate for environment variables that can be overwritten. The more a user knows about a system the more likely she will find a vulnerable environment variable. On a web environment, the attacker can read the client side code and search for environment variables that can be overwritten. There are tools such as Sharefuzz (http://sharefuzz.sourceforge.net/) which is an environment variable fuzzer for Unix that support loading a shared library. Attackers can use such tools to uncover a buffer overflow in an environment variable. | | Indicators-Warnings of Attack | If the application does bound checking, it should fail when the data source is larger than the size of the destination buffer. If the application's code is well written, that failure should triger an alert. | | Solutions and Mitigations | Do not expose environment variable to the user. Do not use untrusted data in your environment variables. Use a language or compiler that performs automatic bounds checking There are tools such as Sharefuzz (http://sharefuzz.sourceforge.net/) which is an environment variable fuzzer for Unixes that support loading a shared library. You can use Sharefuzz to determine if you are exposing an environment variable vulnerable to buffer overflow. | | Attack Motivation-Consequences | - Denial of Service
- Run Arbitrary Code
- Information Leakage
- Data Modification
- Privilege Escalation
| | Injection Vector | The user modifiable environment variable. | | Payload | User supplied data potentially containing malicious code. | | Activation Zone | When the subroutine which uses the environment variable returns control to the main program, it jumps to the return address portion of the stack frame. Unfortunately that return address may have been overwritten by the overflowed buffer and the address may contain a call to a privileged command or to a malicious code. | | Payload Activation Impact | The most common is remote code execution. | | Related Weaknesses | | CWE-ID | Weakness Name | Weakness Relationship Type |
|---|
| 120 | Buffer Copy without Checking Size of Input ('Classic Buffer Overflow') | Targeted | | 302 | Authentication Bypass by Assumed-Immutable Data | Targeted | | 118 | Improper Access of Indexable Resource (aka 'Range Error') | Targeted | | 119 | Failure to Constrain Operations within the Bounds of a Memory Buffer | Targeted | | 74 | Failure to Sanitize Data into a Different Plane (aka 'Injection') | Targeted | | 99 | Insufficient Control of Resource Identifiers (aka 'Resource Injection') | Targeted | | 20 | Improper Input Validation | Targeted | | 680 | Integer Overflow to Buffer Overflow | Targeted | | 733 | Compiler Optimization Removal or Modification of Security-critical Code | Secondary | | 697 | Insufficient Comparison | Targeted |
| | Related Attack Patterns | | ID | Name | Relationship Type | Relationship Description |
|---|
| 100 | Overflow Buffers | More Detailed | |
| | Related Security Principles | | | Related Guidelines | - Bound checking should be performed when copying data to a buffer.
| | Purpose | Penetration | | CIA Impact | | Confidentiality Impact | Integrity Impact | Availability Impact |
|---|
| High | High | High |
| | Technical Context | | Architectural Paradigm | Framework | Platform | Language |
|---|
| All | All | All | All |
| | References | G. Hoglund and G. McGraw. Exploiting Software: How to Break Code. Addison-Wesley, February 2004. CWE - Buffer Errors | | Source | | Submission(s) |
|---|
| Submitter | Organization | Date | Comment |
|---|
| G. Hoglund and G. McGraw. Exploiting Software: How to Break Code. Addison-Wesley, February 2004. | Cigital, Inc | 2007-03-01 | |
| Modification(s) |
|---|
| Modifier | Organization | Date | Comment |
|---|
| Eric Dalci | Cigital, Inc | 2007-02-13 | Fleshed out content to CAPEC schema from the original descriptions in "Exploiting Software" | | Sean Barnum | Cigital, Inc | 2007-03-05 | Review and revise | | Richard Struse | VOXEM, Inc | 2007-03-26 | Review and feedback leading to changes in Name | | Sean Barnum | Cigital, Inc | 2007-04-13 | Modified pattern content according to review and feedback |
|
| Attack Pattern ID | Pattern Abstraction: Detailed 14 | | Typical Severity | High | | Description | Summary This type of attack exploits a buffer overflow vulnerability in targeted client software through injection of malicious content from a custom-built hostile service. Attack Execution Flow The attacker creates a custom hostile service The attacker acquires information about the kind of client attaching to her hostile service to determine if it contains an exploitable buffer overflow vulnerability. The attacker intentionally feeds malicious data to the client to exploit the buffer overflow vulnerability that she has uncovered. The attacker leverages the exploit to execute arbitrary code or to cause a denial of service.
| | Attack Prerequisites | The targeted client software communicates with an external server. The targeted client software has a buffer oveflow vulnerability. | | Typical Likelihood of Exploit |
Medium
| | Methods of Attack | | | Examples-Instances | Description Attack Example: Buffer Overflow in Internet Explorer 4.0 Via EMBED Tag
Authors often use <EMBED> tags in HTML documents. For example <EMBED TYPE="audio/midi" SRC="/path/file.mid" AUTOSTART="true"> If an attacker supplies an overly long path in the SRC= directive, the mshtml.dll component will suffer a buffer overflow. This is a standard example of content in a Web page being directed to exploit a faulty module in the system. There are potentially thousands of different ways data can propagate into a given system, thus these kinds of attacks will continue to be found in the wild. | | Attacker Skill or Knowledge Required | Low : To achieve a denial of service, an attacker can simply overflow a buffer by inserting a long string into an attacker-modifiable injection vector. High : Exploiting a buffer overflow to inject malicious code into the stack of a software system or even the heap requires a more in-depth knowledge and higher skill level. | | Probing Techniques | The server may look like a valid server, but in reality it may be a hostile server aimed at fooling the client software. For instance the server can use honey pots and get the client to download malicious code. Once engaged with the client, the hostile server may attempt to scan the client's host for open ports and potential vulnerabilities in the client software. The hostile server may also attempt to install and run malicious code on the client software. That malicious code can be used to scan the client software for buffer overflow. | | Indicators-Warnings of Attack | An example of indicator is when the client software crashes after executing code downloaded from a hostile server. | | Solutions and Mitigations | The client software should not install untrusted code from a non authenticated server. The client software should have the latest patches and should be audited for vulnerabilities before being used to communicate with potentially hostile servers. Perform input validation for length of buffer inputs. Use a language or compiler that performs automatic bounds checking. Use an abstraction library to abstract away risky APIs. Not a complete solution. Compiler-based canary mechanisms such as StackGuard, ProPolice and the Microsoft Visual Studio /GS flag. Unless this provides automatic bounds checking, it is not a complete solution. Ensure all buffer uses are consistently bounds-checked. Use OS-level preventative functionality. Not a complete solution. | | Attack Motivation-Consequences | - Denial of Service
- Run Arbitrary Code
| | Context Description | "Backwash Attacks: Leveraging Client-side Buffer Overflows
Nothing is more forward than directly attacking those who are attacking you. In many cases this philosophy is instantiated as a series of denial-of-service attacks launched in either direction. In standard scenarios, you can learn what IP address is being used to attack you, and then you can follow up with an attack of your own. (Be forewarned, however, that the legal ramifications of counterattack are drastic.) If the attacker is dumb enough to have open services, you may in some cases be able to own their system. This has led some security types to consider a rather insidious tactic—creating hostile network services that look like valid targets. The basic idea builds on the idea of honey pots, but goes one important step further. Because most client software contains buffer overflows and other vulnerabilities, including a capacity to exploit these weaknesses directly when probed is within the realm of possibility. Not surprisingly, of all the code that gets tested and probed in a security situation, client code is usually ignored. This is one of the reasons that client code ends up with more serious problems than server code. If a vulnerable client attaches to a hostile service, the hostile service can attempt to identify the type and version of the client that is connecting. This is a variety of fingerprinting. Once the client is properly identified, the hostile server can issue a response that exploits a buffer overflow (or some other security defect) in the client. Typically this kind of attack is not designed simply just to crash the client. Attackers using this technique can inject a virus or backdoor into the original attacker's computer using their own connection against them. Obviously, this kind of "backwash attack" is a serious threat to an attacker. Anyone planning to attack arbitrary systems should assume that a backwash attack can and will happen. Any and all client software should be carefully audited before use." | | Payload | Attacker-supplied data potentially containing malicious code. | | Activation Zone | When the function returns control to the main program, it jumps to the return address portion of the stack frame. Unfortunately that return address may have been overwritten by the overflowed buffer and the address may contain a call to a privileged command or to malicious code. | | Payload Activation Impact | The most common are remote code execution or denial of service. | | Related Weaknesses | | CWE-ID | Weakness Name | Weakness Relationship Type |
|---|
| 120 | Buffer Copy without Checking Size of Input ('Classic Buffer Overflow') | Targeted | | 353 | Failure to Add Integrity Check Value | Targeted | | 118 | Improper Access of Indexable Resource (aka 'Range Error') | Targeted | | 119 | Failure to Constrain Operations within the Bounds of a Memory Buffer | Targeted | | 74 | Failure to Sanitize Data into a Different Plane (aka 'Injection') | Targeted | | 20 | Improper Input Validation | Targeted | | 680 | Integer Overflow to Buffer Overflow | Targeted | | 697 | Insufficient Comparison | Targeted | | 713 | OWASP Top Ten 2007 Category A2 - Injection Flaws | Targeted |
| | Related Attack Patterns | | ID | Name | Relationship Type | Relationship Description |
|---|
| 8 | Buffer Overflow in an API Call | More Detailed | |
| | Related Security Principles | - Reluctance to Trust
- Defense in Depth
| | Purpose | Penetration | | CIA Impact | | Confidentiality Impact | Integrity Impact | Availability Impact |
|---|
| High | High | High |
| | Technical Context | | Architectural Paradigm | Framework | Platform | Language |
|---|
| Client-Server | All | All | All |
| | References | G. Hoglund and G. McGraw. Exploiting Software: How to Break Code. Addison-Wesley, February 2004. CWE - Buffer Errors | | Source | | Submission(s) |
|---|
| Submitter | Organization | Date | Comment |
|---|
| G. Hoglund and G. McGraw. Exploiting Software: How to Break Code. Addison-Wesley, February 2004. | Cigital, Inc | 2007-03-01 | |
| Modification(s) |
|---|
| Modifier | Organization | Date | Comment |
|---|
| Eric Dalci | Cigital, Inc | 2007-02-13 | Fleshed out content to CAPEC schema from the original descriptions in "Exploiting Software" | | Sean Barnum | Cigital, Inc | 2007-03-05 | Review and revise | | Richard Struse | VOXEM, Inc | 2007-03-26 | Review and feedback leading to changes in Related Attack Patterns | | Sean Barnum | Cigital, Inc | 2007-04-13 | Modified pattern content according to review and feedback |
|
| Attack Pattern ID | Pattern Abstraction: Detailed 16 | | Typical Severity | High | | Description | Summary An attacker tries each of the words in a dictionary as passwords to gain access to the system via some user's account. If the password chosen by the user was a word within the dictionary, this attack will be successful (in the absence of other mitigations). This is a specific instance of the password brute forcing attack pattern. Attack Execution Flow Explore Determine application's/system's password policy: Determine the password policies of the target application/system. | Attack Step
Techniques |
|---|
| Description | Environments |
|---|
| Determine minimum and maximum allowed password lengths. | env-All | | Determine format of allowed passwords (whether they are required or allowed to contain numbers, special characters, etc., or whether they are allowed to contain words from the dictionary). | env-All | | Determine account lockout policy (a strict account lockout policy will prevent brute force attacks). | env-All |
| Indicators of
Susceptibility |
|---|
| ID | Type | Description | Environments |
|---|
| c49s0i1 | Positive | Passwords are used in the application/system | env-All | | c49s0i2 | Negative | Passwords are not used in the application/system. | env-All |
Select dictionaries: Pick the dictionaries to be used in the attack (e.g. different languages, specific terminology, etc.) | Attack Step
Techniques |
|---|
| Description | Environments |
|---|
| Select dictionary based on particular users' preferred languages. | env-All | | Select dictionary based on the application/system's supported languages. | env-All |
Determine username(s) to target: Determine username(s) whose passwords to crack. | Attack Step
Techniques |
|---|
| Description | Environments |
|---|
| Obtain username(s) by sniffing network packets. | env-CommProtocol env-Peer2Peer env-ClientServer | | Obtain username(s) by querying application/system (e.g. if upon a failed login attempt, the system indicates whether the entered username was valid or not) | env-All | | Obtain usernames from filesystem (e.g. list of directories in C:\Documents and Settings\ in Windows, and list in /etc/passwd in UNIX-like systems) | env-Embedded env-Local |
| Indicator of
Susceptibility |
|---|
| ID | Type | Description | Environments |
|---|
| c16s2i1 | Negative | Remote application or system provides no indication regarding whether a given username is valid or not. | env-ClientServer env-Peer2Peer env-Web env-CommProtocol |
| Outcomes |
|---|
| ID | Type | Description |
|---|
| c16s2o1 | Success | At least one valid username found. | | c16s2o2 | Failure | Presence of any valid usernames could not be established. |
| Security
Controls |
|---|
| ID | Type | Description |
|---|
| c16s2sc1 | Preventative | Do not reveal information regarding validity of particular usernames to users. | | c16s2sc2 | Corrective | Lock out accounts whose usernames are suspected to have been compromised. |
Exploit Use dictionary to crack passwords.: Use a password cracking tool that will leverage the dictionary to feed passwords to the system and see if they work. | Attack Step
Techniques |
|---|
| Description | Environments |
|---|
| Try all words in the dictionary, as well as common misspellings of the words as passwords for the chosen username(s). | env-All | | Try common combinations of words in the dictionary, as well as common misspellings of the combinations as passwords for the chosen username(s). | env-All |
| Indicator of
Susceptibility |
|---|
| ID | Type | Description | Environments |
|---|
| c16s3i1 | Negative | Application/system does not use password authentication. | env-All |
| Outcomes |
|---|
| ID | Type | Description |
|---|
| c16s3o1 | Success | Attacker determines correct password for a user ID and obtains access to application or system. | | c16s3o2 | Failure | Attacker is unable to determine correct password for a user ID and obtain access to application or system. |
| Security
Controls |
|---|
| ID | Type | Description |
|---|
| c16s3sc1 | Detective | Large number of authentication failures in logs. | | c16s3sc2 | Preventative | Enforce strict account lockout policies. | | c16s3sc3 | Preventative | Enforce strong passwords (having sufficient length and containing mix of lower case and upper case letters, numbers, and special characters) |
| | Attack Prerequisites | The system uses one factor password based authentication. The system does not have a sound password policy that is being enforced. The system does not implement an effective password throttling mechanism. | | Typical Likelihood of Exploit |
Medium
| | Methods of Attack | | | Examples-Instances | Description A system user selects the word "treacherous" as their passwords believing that it would be very difficult to guess. The password-based dictionary attack is used to crack this password and gain access to the account. Description The Cisco LEAP challenge/response authentication mechanism uses passwords in a way that is susceptible to dictionary attacks, which makes it easier for remote attackers to gain privileges via brute force password guessing attacks. Cisco LEAP is a mutual authentication algorithm that supports dynamic derivation of session keys. With Cisco LEAP, mutual authentication relies on a shared secret, the user's logon password—which is known by the client and the network, and is used to respond to challenges between the user and the Remote Authentication Dial-In User Service (RADIUS) server. Methods exist for someone to write a tool to launch an offline dictionary attack on password-based authentications that leverage Microsoft MS-CHAP, such as Cisco LEAP. The tool leverages large password lists to efficiently launch offline dictionary attacks against LEAP user accounts, collected through passive sniffing or active techniques. Related Vulnerability | | Attacker Skill or Knowledge Required | Low: A variety of password cracking tools and dictionaries are available to launch this type of an attack. | | Resources Required | A machine with sufficient resources for the job (e.g. CPU, RAM, HD). Applicable dictionaries are required. Also a password cracking tool or a custom script that leverages the dictionary database to launch the attack. | | Indicators-Warnings of Attack | Many invalid login attempts are coming from the same machine (same IP address) or for the same log in name. The login attempts use passwords that are dictionary words. | | Obfuscation Techniques | Employ IP spoofing to make it seem like login attempts are coming from different machines. | | Solutions and Mitigations | Create a strong password policy and ensure that your system enforces this policy. Implement an intelligent password throttling mechanism. Care must be taken to assure that these mechanisms do not excessively enable account lockout attacks such as CAPEC-02. | | Attack Motivation-Consequences | | | Related Weaknesses | | CWE-ID | Weakness Name | Weakness Relationship Type |
|---|
| 521 | Weak Password Requirements | Targeted | | 262 | Not Using Password Aging | Targeted | | 263 | Password Aging with Long Expiration | Targeted | | 693 | Protection Mechanism Failure | Targeted |
| | Related Attack Patterns | | ID | Name | Relationship Type | Relationship Description |
|---|
| 49 | Password Brute Forcing | More Abstract | | | 70 | Try Common(default) Usernames and Passwords | More Detailed | | | 55 | Rainbow Table Password Cracking | Occasionally Follows | |
| | Purpose | Penetration | | CIA Impact | | Confidentiality Impact | Integrity Impact | Availability Impact |
|---|
| High | Medium | Low |
| | Technical Context | | Architectural Paradigm | Framework | Platform | Language |
|---|
| All | All | All | All |
| | Source | | Submission(s) |
|---|
| Submitter | Organization | Date | Comment |
|---|
| Eugene Lebanidze | Cigital, Inc | 2007-02-26 | |
| Modification(s) |
|---|
| Modifier | Organization | Date | Comment |
|---|
| Sean Barnum | Cigital, Inc | 2007-03-01 | Review and revision of content | | Richard Struse | VOXEM, Inc | 2007-03-26 | Review and feedback leading to changes in Solutions | | Sean Barnum | Cigital, Inc | 2007-04-13 | Modified pattern content according to review and feedback | | Amit Sethi | Cigital, Inc. | 2007-10-29 | Added extended Attack Execution Flow |
|
| Attack Pattern ID | Pattern Abstraction: Detailed 24 | | Typical Severity | High | | Description | Summary In this attack, the idea is to cause an active filter to fail by causing an oversized transaction. An attacker may try to feed overly long input strings to the program in an attempt to overwhelm the filter (by causing a buffer overflow) and hoping that the filter does not fail securely (i.e. lets the user input into the system unfiltered). Attack Execution Flow Explore Survey: The attacker surveys the target application, possibly as a valid and authenticated user | Attack Step
Techniques |
|---|
| Description | Environments |
|---|
| Spidering web sites for inputs that involve potential filtering | env-Web | | Brute force guessing of filtered inputs | env-All |
| Indicators of
Susceptibility |
|---|
| ID | Type | Description | Environments |
|---|
| c24s1i1 | Positive | Software messages (e.g., "the following characters are not allowed...") indicate that filtered inputs are present in the software. ( | env-Web env-ClientServer | | c24s1i2 | Positive | Application uses predefined inputs (e.g., drop-down lists, radio buttons, selection lists, etc.) | env-Web env-ClientServer env-Local env-Embedded | | c24s1i3 | Negative | Managed code (e.g., .NET, Java) is likely, based on URLs. | env-Web | | c24s1i4 | Negative | Managed code (e.g., .NET, Java) is likely, based on files found in software. | env-ClientServer env-Local env-Embedded env-Peer2Peer env-CommProtocol | | c24s1i5 | Negative | Java code is likely, based on standard disclaimers (e.g., "This software contains Java from Sun...."). Such declarations are frequent on commercial software that is based on Java. | env-Embedded env-Local env-ClientServer | | c24s1i6 | Inconclusive | Java code is likely, based on one of the other indicators, but it could contain Java Native Interface (JNI) code. This is indicated by the inclusion of DLLs or equivalent binary object code with Java code. | env-Embedded env-Local env-ClientServer |
Experiment Attempt injections: Try to feed overly long data to the system. This can be done manually or a dynamic tool (black box) can be used to automate this. An attacker can also use a custom script for that purpose. | Attack Step
Techniques |
|---|
| Description | Environments |
|---|
| Brute force attack through black box penetration test tool. | env-Web env-ClientServer env-CommProtocol env-Peer2Peer | | Fuzzing of communications protocols | env-CommProtocol env-Peer2Peer env-ClientServer | | Manual testing of possible inputs with attack data. | env-All |
| Outcomes |
|---|
| ID | Type | Description |
|---|
| c24s2o1 | Success | Unexpected output from the application. | | c24s2o2 | Failure | No unexpected output from the application. |
| Security
Controls |
|---|
| ID | Type | Description |
|---|
| c24s2s1 | Detective | Monitor and analyze logs for failures that exceed common usage sizes. For example, if typical transactions, even normal failed transactions, rarely exceed 250 characters, monitor logs for all attempts that contain 250 or more characters. In the event of successful exploitation, there may actually be no useful log. But an attacker's experiments will likely show up, giving clues to the ultimate attack. | | c24s2s2 | Corrective | Disconnect or block connections from systems or users that exceed acceptable heuristics for normal transaction sizes. |
Monitor responses: Watch for any indication of failure occurring. Carefully watch to see what happened when filter failure occurred. Did the data get in? | Attack Step
Techniques |
|---|
| Description | Environments |
|---|
| Boron tagging. Choose clear attack inputs that are easy to notice in output. In binary this is often 0xa5a5a5a5 (alternating 1s and 0s). Another obvious tag value is all zeroes, but it is not always obvious what goes wrong if the null values get into the data. | env-All | | Check Log files. An attacker with access to log files can look at the outcome of bad input. | env-Local env-Embedded |
| Security
Controls |
|---|
| ID | Type | Description |
|---|
| c24s3s1 | Preventative | Prevent access to log files that contain error output. | | c24s3s2 | Preventative | Prevent access to and/or sanitize all error output. |
Exploit Abuse the system through filter failure: An attacker writes a script to consistently induce the filter failure. | Attack Step
Techniques |
|---|
| Description | Environments |
|---|
| DoS through filter failure. The attacker causes the system to crash or stay down because of its failure to filter properly. | env-All | | Malicious code execution. An attacker introduces a malicious payload and executes arbitrary code on the target system. | env-All | | An attacker can use the filter failure to introduce malicious data into the system and leverage a subsequent SQL injection, Cross Site Scripting, Command Injection or similar weakness if it exists. | env-All |
| Indicators of
Susceptibility |
|---|
| ID | Type | Description | Environments |
|---|
| c24s4i1 | Positive | Failure mode of the software (perhaps as a safety mechanism) includes exiting or ceasing to respond. | env-All | | c24s4i2 | Negative | Failures do not involve stopping services, rejecting inputs or connections, and do not affect other simultaneous users of the software. | env-All |
| Outcomes |
|---|
| ID | Type | Description |
|---|
| c24s4o1 | Success | Attacker-supplied code is executed on the target system. | | c24s4o2 | Success | The software stops responding for at least two orders of magnitude longer than the input takes to send. (e.g., 0.1s to send input induces at least a 10 second period non-responsiveness). | | c24s4o3 | Success | Non-response by an attacker's input has an impact on the quality of service of other simultaneous users of the software. |
| Security
Controls |
|---|
| ID | Type | Description |
|---|
| c24s4s1 | Detective | Monitor software response time regularly, and react to unexpected variations. | | c24s4s2 | Preventative | Execute filtering modules with minimal privileges. | | c24s4s3 | Preventative | Execute filtering modules in operating system "sandboxes" or similar containers. |
| | Attack Prerequisites | Ability to control the length of data passed to an active filter. | | Typical Likelihood of Exploit |
High
| | Methods of Attack | | | Examples-Instances | Description Attack Example: Filter Failure in Taylor UUCP Daemon Sending in arguments that are too long to cause the filter to fail open is one instantiation of the filter failure attack. The Taylor UUCP daemon is designed to remove hostile arguments before they can be executed. If the arguments are too long, however, the daemon fails to remove them. This leaves the door open for attack. Description A filter is used by a web application to filter out characters that may allow the input to jump from the data plane to the control plane when data is used in a SQL statement (chaining this attack with the SQL injection attack). Leveraging a buffer overflow the attacker makes the filter fail insecurely and the tainted data is permitted to enter unfiltered into the system, subsequently causing a SQL injection. Description Audit Truncation and Filters with Buffer Overflow. Sometimes very large transactions can be used to destroy a log file or cause partial logging failures. In this kind of attack, log processing code might be examining a transaction in real-time processing, but the oversized transaction causes a logic branch or an exception of some kind that is trapped. In other words, the transaction is still executed, but the logging or filtering mechanism still fails. This has two consequences, the first being that you can run transactions that are not logged in any way (or perhaps the log entry is completely corrupted). The second consequence is that you might slip through an active filter that otherwise would stop your attack. | | Attacker Skill or Knowledge Required | Low : An attacker can simply overflow a buffer by inserting a long string into an attacker-modifiable injection vector. The result can be a DoS. High : Exploiting a buffer overflow to inject malicious code into the stack of a software system or even the heap can require a higher skill level. | | Probing Techniques | Try to feed very long data as input to the program and watch for any indication that a failure has occurred. Then see if input has been admitted into the system. Some dynamic analysis tools may be helpful here to determine whether failure can be induced by feeding overly long inputs strings into the system. | | Indicators-Warnings of Attack | Many exceptions are thrown by the application's filter modules in a short period of time. Check the logs. See if the probes are coming from the same IP address. | | Obfuscation Techniques | An attacker may temporally space out their probes. An attacker may perform probes from different IP addresses. | | Solutions and Mitigations | Make sure that ANY failure occurring in the filtering or input validation routine is properly handled and that offending input is NOT allowed to go through. Basically make sure that the vault is closed when failure occurs. Pre-design: Use a language or compiler that performs automatic bounds checking. Pre-design through Build: Compiler-based canary mechanisms such as StackGuard, ProPolice and the Microsoft Visual Studio /GS flag. Unless this provides automatic bounds checking, it is not a complete solution. Operational: Use OS-level preventative functionality. Not a complete solution. Design: Use an abstraction library to abstract away risky APIs. Not a complete solution. | | Attack Motivation-Consequences | - Run Arbitrary Code
- Privilege Escalation
- Denial of Service
| | Injection Vector | Web form, URL, File, Command line, Network socket, etc. | | Payload | All of the data that just got into the system unfiltered becomes the payload. | | Activation Zone | Since the input enters the system effectively unfiltered, it may be dangerous if used in a SQL statement (i.e. SQL injection), as part of the command executed on the target system (i.e. command injection), as part of the reflection API (i.e. reflection injection), placed in logs (i.e. log injection), or perhaps to overflow another buffer in the system and give the attacker ability to execute arbitrary code. A subsequent buffer overflow may not even be required for that as the original one may be leveraged if the attacker gets lucky, that is the payload is activated in the filter itself, which also becomes the activation zone. | | Payload Activation Impact | Since no input validation is effectively performed in this situation, the impact of the attack may be a complete compromise of confidentiality, integrity, accountability and availability services. | | Related Weaknesses | | CWE-ID | Weakness Name | Weakness Relationship Type |
|---|
| 120 | Buffer Copy without Checking Size of Input ('Classic Buffer Overflow') | Targeted | | 119 | Failure to Constrain Operations within the Bounds of a Memory Buffer | Targeted | | 118 | Improper Access of Indexable Resource (aka 'Range Error') | Targeted | | 74 | Failure to Sanitize Data into a Different Plane (aka 'Injection') | Targeted | | 20 | Improper Input Validation | Targeted | | 680 | Integer Overflow to Buffer Overflow | Targeted | | 733 | Compiler Optimization Removal or Modification of Security-critical Code | Secondary | | 697 | Insufficient Comparison | Targeted |
| | Related Attack Patterns | | ID | Name | Relationship Type | Relationship Description |
|---|
| 100 | Overflow Buffers | Occasionally Follows | |
| | Relevant Security Requirements | Input validation and filtering logic should fail securely (vault doors are closed) | | Related Security Principles | | | Related Guidelines | - All input should be treated as rejected by default, unless explicitly allowed by the filter. Thus if the filter fails before "blessing" the data, it will be rejected.
| | Purpose | Penetration | | CIA Impact | | Confidentiality Impact | Integrity Impact | Availability Impact |
|---|
| Medium | High | Medium |
| | Technical Context | | Architectural Paradigm | Framework | Platform | Language |
|---|
| All | All | All | All |
| | References | G. Hoglund and G. McGraw. Exploiting Software: How to Break Code. Addison-Wesley, February 2004. CWE - Buffer Errors | | Source | | Submission(s) |
|---|
| Submitter | Organization | Date | Comment |
|---|
| G. Hoglund and G. McGraw. Exploiting Software: How to Break Code. Addison-Wesley, February 2004. | Cigital, Inc | 2007-03-01 | |
| Modification(s) |
|---|
| Modifier | Organization | Date | Comment |
|---|
| Eugene Lebanidze | Cigital, Inc | 2007-02-26 | Fleshed out content to CAPEC schema from the original descriptions in "Exploiting Software" | | Sean Barnum | Cigital, Inc | 2007-03-05 | Review and revise | | Paco Hope | Cigital, Inc. | 2007-10-20 | Added extended Attack Execution Flow |
|
| Attack Pattern ID | Pattern Abstraction: Detailed 27 | | Typical Severity | High | | Description | Summary This attack leverages the use of symbolic links (Symlinks) in order to write to sensitive files. An attacker can create a Symlink link to a target file not otherwise accessible to her. When the privileged program tries to create a temporary file with the same name as the Symlink link, it will actually write to the target file pointed to by the attacker's Symlink link. If the attacker can insert malicious content in the temporary file she will be writing to the sensitive file by using the Symlink. The race occurs because the system checks if the temporary file exists, then creates the file. The attacker would typically create the Symlink during the interval between the check and the creation of the temporary file. Attack Execution Flow Explore Verify that target host's platform supports symbolic links.: This attack pattern is only applicable on platforms that support symbolic links. | Attack Step
Techniques |
|---|
| Description | Environments |
|---|
| Research target platform to determine whether it supports symbolic links. | env-Embedded env-Local | | Create a symbolic link and ensure that it works as expected on the given platform. | env-Embedded env-Local |
| Outcomes |
|---|
| ID | Type | Description |
|---|
| c27s0o1 | Success | Target platform supports symbolic links (e.g. Linux, UNIX, etc.) | | c27s0o2 | Failure | Target platform does not support symbolic links (e.g. MS Windows) |
Examine application's file I/O behavior: Analyze the application's file I/O behavior to determine where it stores files, as well as the operations it performs to read/write files. | Attack Step
Techniques |
|---|
| Description | Environments |
|---|
| Use kernel tracing utility such as ktrace to monitor application behavior | env-Local | | Use debugging utility such as File Monitor to monitor the application's filesystem I/O calls | env-Local | | Watch temporary directories to see when temporary files are created, modified and deleted. | env-Embedded env-Local | | Analyze source code for open-source systems like Linux, Apache, etc. | env-Embedded env-Local |
| Indicators of
Susceptibility |
|---|
| ID | Type | Description | Environments |
|---|
| c27s1i1 | Positive | Attacker can watch files being created, modified and/or deleted by application. | env-Embedded env-Local | | c27s1i2 | Inconclusive | Application does not seem to perform any filesystem I/O operations. | env-Embedded env-Local |
| Outcomes |
|---|
| ID | Type | Description |
|---|
| c27s1o1 | Success | Attacker identifies at least one reproducable file I/O operation performed by the application. | | c27s1o2 | Failure | Attacker cannot identify any file I/O operations being performed by the application. |
Experiment Verify ability to write to filesystem: The attacker verifies ability to write to the target host's file system. | Attack Step
Techniques |
|---|
| Description | Environments |
|---|
| Create a file that does not exist in the target directory (e.g. "touch temp.txt" in UNIX-like systems) | env-Embedded env-Local | | On platforms that differentiate between file creation and file modification, if the target file that the application writes to already exists, attempt to modify it. | env-Embedded env-Local | | Verify permissions on target directory | env-Embedded env-Local |
| Indicators of
Susceptibility |
|---|
| ID | Type | Description | Environments |
|---|
| c27s3i1 | Positive | Target directory is a globally writable temp directory (e.g. /tmp in many UNIX-like systems) | env-Embedded env-Local | | c27s3i2 | Positive | Target directory is writable by the attacker's effective user ID. | env-Embedded env-Local |
| Outcomes |
|---|
| ID | Type | Description |
|---|
| c27s3o1 | Success | Attacker can create and modify files in the target directory. | | c27s3o2 | Failure | Attacker cannot create or modify files in the target directory. |
| Security
Control |
|---|
| ID | Type | Description |
|---|
| c27s3sc1 | Preventative | Store temporary files in a directory with limited permissions where malicious users cannot tamper with them. |
Exploit Replace file with a symlink to a sensitive system file.: Between the time that the application checks to see if a file exists (or if the user has access to it) and the time the application actually opens the file, the attacker replaces the file with a symlink to a sensitive system file. | Attack Step
Techniques |
|---|
| Description | Environments |
|---|
| Create an infinite loop containing commands such as "rm -f tempfile.dat; ln -s /etc/shadow tempfile.dat". Wait for an instance where the following steps occur in the given order: (1) Application ensures that tempfile.dat exists and that the user has access to it, (2) "rm -f tempfile.dat; ln -s /etc/shadow tempfile.dat", and (3) Application opens tempfile.dat for writing, and inadvertently opens /etc/shadow for writing instead. | env-Embedded env-Local | | Use other techniques with debugging tools to replace the file between the time the application checks the file and the time the application opens it. | env-Embedded env-Local |
| Outcomes |
|---|
| ID | Type | Description |
|---|
| c27s4o1 | Success | Sensitive file tampered with successfully. | | c27s4o2 | Failure | Sensitive file could not be tampered with. |
| Security
Controls |
|---|
| ID | Type | Description |
|---|
| c27s4sc1 | Preventative | Use file handles to check existence of files, to check permissions and to open them. Do not use filename except to obtain a handle initially. | | c27s4sc2 | Preventative | Drop application's permissions to the current user's permissions before performing any file I/O operations (e.g. using Process.as_uid() in Ruby). | | c27s4sc3 | Corrective | Run application with minimal permissions. In particular, avoid running applications as root on UNIX-like systems and as Administrator on Windows systems. |
| | Attack Prerequisites | The attacker is able to create Symlink links on the target host. Tainted data from the attacker is used and copied to temporary files. The target host does insecure temporary file creation. | | Typical Likelihood of Exploit |
Medium
| | Methods of Attack | - Injection
- Time and State
- Modification of Resources
| | Examples-Instances | Description In this naive example, the Unix program foo is setuid. Its function is to retrieve information for the accounts specified by the user. For "efficiency," it sorts the requested accounts into a temporary file (/tmp/foo naturally) before making the queries.
The directory /tmp is world-writable. Malicious user Mallory creates a symbolic link to the file /.rhosts named /tmp/foo. Then, she invokes foo with + + as the requested account. The program creates the (temporary) file /tmp/foo (really creating /.rhosts) and puts the requested account (+ +) in it. It removes the temporary file (merely removing the symbolic link). Now the /.rhosts contains + +, which is the incantation necessary to allow anyone to use rlogin to log into the computer as the superuser. (Source : Wikipedia (http://en.wikipedia.org/wiki/Symlink_race)). Description GNU ed before 0.3 allows local users to overwrite arbitrary files via a symlink attack on temporary files, possibly in the open_sbuf function. Related Vulnerability Description OpenmosixCollector and OpenMosixView in OpenMosixView 1.5 allow local users to overwrite or delete arbitrary files via a symlink attack on (1) temporary files in the openmosixcollector directory or (2) nodes.tmp. Related Vulnerability Description Setuid product allows file reading by replacing a file being edited with a symlink to the targeted file, leaking the result in error messages when parsing fails. Related Vulnerability | | Attacker Skill or Knowledge Required | Medium/High: This attack is sophisticated because the attacker has to overcome a few challenges such as creating symlinks on the target host during a precise timing, inserting malicious data in the temporary file and have knowledge about the temporary files created (file name and function which creates them). | | Probing Techniques | The attacker will certainly look for file system locations where he can write and create Symlink links. The attacker may also observe the system and locate the temporary files created during a call to a certain function. | | Solutions and Mitigations | Use safe libraries when creating temporary files. For instance the standard library function mkstemp can be used to safely create temporary files. For shell scripts, the system utility mktemp does the same thing. Access to the directories should be restricted as to prevent attackers from manipulating the files. Denying access to a file can prevent an attacker from replacing that file with a link to a sensitive file. Follow the principle of least privilege when assigning access rights to files. Ensure good compartmentalization in the system to provide protected areas that can be trusted. | | Attack Motivation-Consequences | - Data Modification
- Privilege Escalation
- Denial of Service
| | Injection Vector | The content of the temporary file which is copied to the file pointed to by the Symlink. | | Payload | The content of the file overwriten when writing to the Symlink. | | Activation Zone | The new content of the targeted file. | | Payload Activation Impact | This attack can cause privilege escalation, modification of resources or denial of services. | | Related Weaknesses | | CWE-ID | Weakness Name | Weakness Relationship Type |
|---|
| 367 | Time-of-check Time-of-use (TOCTOU) Race Condition | Targeted | | 61 | UNIX Symbolic Link (Symlink) Following | Targeted | | 662 | Insufficient Synchronization | Targeted | | 689 | Permission Race Condition During Resource Copy | Targeted | | 667 | Insufficient Locking | Targeted |
| | Related Attack Patterns | | ID | Name | Relationship Type | Relationship Description |
|---|
| 29 | Leveraging Time-of-Check and Time-of-Use (TOCTOU) Race Conditions | More Detailed | | | 26 | Leveraging Race Conditions | More Detailed | |
| | Related Security Principles | | | Purpose | Exploitation | | CIA Impact | | Confidentiality Impact | Integrity Impact | Availability Impact |
|---|
| High | High | Low |
| | Technical Context | | Architectural Paradigm | Framework | Platform | Language |
|---|
| All | All | All | All |
| | References | Symlink Race, Wikipedia - http://en.wikipedia.org/wiki/Symlink_race Safe temporary file creation with mkstemp - http://www.opengroup.org/onlinepubs/009695399/functions/mkstemp.html | | Source | | Submission(s) |
|---|
| Submitter | Organization | Date | Comment |
|---|
| Eric Dalci | Cigital, Inc | 2007-02-01 | |
| Modification(s) |
|---|
| Modifier | Organization | Date | Comment |
|---|
| Sean Barnum | Cigital, Inc | 2007-03-08 | Review and revise | | Richard Struse | VOXEM, Inc | 2007-03-26 | Review and feedback leading to changes in Name, Description, Likelihood and Related Attack Patterns | | Sean Barnum | Cigital, Inc | 2007-04-13 | Modified pattern content according to review and feedback | | Amit Sethi | Cigital, Inc. | 2007-10-29 | Added extended Attack Execution Flow |
|
| Attack Pattern ID | Pattern Abstraction: Detailed 31 | | Typical Severity | High | | Description | Summary This attack relies on the use of HTTP Cookies to store credentials, state information and other critical data on client systems.
The first form of this attack involves accessing HTTP Cookies to mine for potentially sensitive data contained therein. The second form of this attack involves intercepting this data as it is transmitted from client to server. This intercepted information is then used by the attacker to impersonate the remote user/session. The third form is when the cookie's content is modified by the attacker before it is sent back to the server. Here the attacker seeks to convince the target server to operate on this falsified information. Attack Execution Flow Explore Obtain copy of cookie: The attacker first needs to obtain a copy of the cookie. The attacker may be a legitimate end user wanting to escalate privilege, or could be somebody sniffing on a network to get a copy of HTTP cookies. | Attack Step
Techniques |
|---|
| Description | Environments |
|---|
| Obtain cookie from local filesystem (e.g. C:\Documents and Settings\*\Cookies and C:\Documents and Settings\*\Application Data\Mozilla\Firefox\Profiles\*\cookies.txt in Windows) | env-Web | | Sniff cookie using a network sniffer such as Wireshark | env-Web | | Obtain cookie from local memory or filesystem using a utility such as the Firefox Cookie Manager or AnEC Cookie Editor. | env-Web | | Steal cookie via a cross-site scripting attack. | env-Web | | Guess cookie contents if it contains predictable information. | env-Web |
| Indicators of
Susceptibility |
|---|
| ID | Type | Description | Environments |
|---|
| c31s1i1 | Positive | Cookies used in web application. | env-Web | | c31s1i2 | Negative | Cookies not used in web application. | env-Web |
| Outcomes |
|---|
| ID | Type | Description |
|---|
| c31s1o1 | Success | Cookie captured by attacker. | | c31s1o2 | Failure | Cookie cannot be captured by attacker. |
| Security
Control |
|---|
| ID | Type | Description |
|---|
| c31s1sc1 | Preventative | To prevent network sniffing, cookies should be transmitted over HTTPS and not plain HTTP. To enforce this on the client side, the "secure" flag should be set on cookies (javax.servlet.http.Cookie.setSecure() in Java, secure flag in setcookie() function in php, etc.). |
Experiment Obtain sensitive information from cookie: The attacker may be able to get sensitive information from the cookie. The web application developers may have assumed that cookies are not accessible by end users, and thus, may have put potentially sensitive information in them. | Attack Step
Techniques |
|---|
| Description | Environments |
|---|
| If cookie shows any signs of being encoded using a standard scheme such as base64, decode it. | env-Web | | Analyze the cookie's contents to determine whether it contains any sensitive information. | env-Web |
| Indicators of
Susceptibility |
|---|
| ID | Type | Description | Environments |
|---|
| c31s2i1 | Negative | Cookie only contains a random session ID (e.g. ASPSESSIONID, JSESSIONID, etc.) | env-Web | | c31s2i2 | Positive | Cookie contains sensitive information (e.g. "ACCTNO=0234234", or "DBIP=0xaf112a22" -- database server's IP address). | env-Web | | c31s2i3 | Inconclusive | Cookie's contents cannot be deciphered. | env-Web |
| Outcomes |
|---|
| ID | Type | Description |
|---|
| c31s2o1 | Success | Cookie contains sensitive information that developer did not intent the end user to see. | | c31s2o2 | Failure | Cookie does not contain any sensitive information. |
| Security
Control |
|---|
| ID | Type | Description |
|---|
| c31s2sc1 | Preventative | Do not store sensitive information in cookies unless they are encrypted such that only the server can decrypt them. |
Modify cookie to subvert security controls.: The attacker may be able to modify or replace cookies to bypass security controls in the application. | Attack Step
Techniques |
|---|
| Description | Environments |
|---|
| Modify logical parts of cookie and send it back to server to observe the effects. | env-Web | | Modify numeric parts of cookie arithmetically and send it back to server to observe the effects. | env-Web | | Modify cookie bitwise and send it back to server to observe the effects. | env-Web | | Replace cookie with an older legitimate cookie and send it back to server to observe the effects. This technique would be helpful in cases where the cookie contains a "points balance" for a given user where the points have some value. The user may spend his points and then replace his cookie with an older one to restore his balance. | env-Web |
| Outcomes |
|---|
| ID | Type | Description |
|---|
| c31s3o1 | Success | Subversion of security controls on server | | c31s3o2 | Failure | Cookie reset by server |
| Security
Controls |
|---|
| ID | Type | Description |
|---|
| c31s3sc1 | Detective | Web server logs contain many messages indicating that invalid cookies were received from client. | | c31s3sc2 | Preventative | Cookies should not contain any information that the user is not allowed to modify, unless that information is never expected to change. In the latter case, the integrity of the cookie should be protected using a digital signature or a message authentication code. |
| | Attack Prerequisites | Target server software must be a HTTP daemon that relies on cookies. | | Typical Likelihood of Exploit |
High
| | Methods of Attack | - Modification of Resources
- API Abuse
- Protocol Manipulation
- Time and State
| | Examples-Instances | Description There are two main attack vectors for exploiting poorly protected session variables like cookies. One is the local machine itself which can be exploited directly at the physical level or indirectly through XSS and phising. In addition, the man in the middle attack relies on a network sniffer, proxy, or other intermediary to intercept the subject's credentials and use them to impersonate the digital subject on the host. The issue is that once the credentials are intercepted, impersonation is trivial for the attacker to accomplish if no other protection mechanisms are in place. | | Attacker Skill or Knowledge Required | Low: To overwrite session cookie data, and submit targeted attacks via HTTP High: Exploiting a remote buffer overflow generated by attack | | Resources Required | Ability to send HTTP request containing cookie to server | | Solutions and Mitigations | Design: Use input validation for cookies Design: Generate and validate MAC for cookies Implementation: Use SSL/TLS to protect cookie in transit Implementation: Ensure the web server implements all relevant security patches, many exploitable buffer overflows are fixed in patches issued for the software. | | Attack Motivation-Consequences | - Information Leakage
- Data Modification
- Privilege Escalation
| | Context Description | One of the biggest challenges in distributed systems is communicating state between the client and server. A variety of schemes have been used, the de facto standard in web application is HTTP cookies. Because these cookies tie together a client and a server through a session, they are useful to system designers and attackers. Because cookies contain remote generated content they can also contain attack payloads.
Cookies may contain a variety of data that servers use to enforce security policy, including session ID, cookie issuer, cookie issuance timestamp, session timeout, subject IP address, and MAC, however the HTTP server should not assume that the session cookie variables are invulnerable. They may be overwritten by the client and/or intermediaries. Cookies, like "hidden" HTML form fields, are generally assumed by developers to be invisible from a client standpoint, but in fact they are a target. From a privacy standpoint, cookies leave a digital audit trail that can violate a digital subject's privacy, cookies may persist personal information on hard drives, in browser cache, log files, proxy servers, and other intermediaries. "Because HTTP is a stateless protocol, cookies (small files that are stored in a client browser) were invented, mostly to preserve state. Poor design of cookie handling systems leaves both clients and HTTP daemons susceptible to buffer overflow attack." [Hoglund and McGraw 04] | | Injection Vector | HTTP cookie | | Payload | Malicious input delivered through cookie in HTTP Request. | | Activation Zone | Client software, such as a browser and its component libraries, or an intermediary | | Payload Activation Impact | 1. Enables attacker to leverage state stored in cookie 2. Enables attacker a vector to attack web server and platform | | Related Weaknesses | | CWE-ID | Weakness Name | Weakness Relationship Type |
|---|
| 565 | Use of Cookies in Security Decision | Targeted | | 302 | Authentication Bypass by Assumed-Immutable Data | Targeted | | 113 | Failure to Sanitize CRLF Sequences in HTTP Headers (aka 'HTTP Response Splitting') | Targeted | | 539 | Information Leak Through Persistent Cookies | Targeted | | 20 | Improper Input Validation | Targeted | | 315 | Plaintext Storage in a Cookie | Targeted | | 384 | Session Fixation | Targeted | | 472 | External Control of Assumed-Immutable Web Parameter | Secondary | | 724 | OWASP Top Ten 2004 Category A3 - Broken Authentication and Session Management | Targeted | | 602 | Client-Side Enforcement of Server-Side Security | Targeted | | 642 | External Control of Critical State Data | Targeted |
| | Purpose | Exploitation | | CIA Impact | | Confidentiality Impact | Integrity Impact | Availability Impact |
|---|
| High | High | Low |
| | Technical Context | | Architectural Paradigm | Framework | Platform | Language |
|---|
| Client-Server | All | All | All |
| | References | G. Hoglund and G. McGraw. Exploiting Software: How to Break Code. Addison-Wesley, February 2004. | | Source | | Submission(s) |
|---|
| Submitter | Organization | Date | Comment |
|---|
| G. Hoglund and G. McGraw. Exploiting Software: How to Break Code. Addison-Wesley, February 2004. | Cigital, Inc | 2007-01-01 | |
| Modification(s) |
|---|
| Modifier | Organization | Date | Comment |
|---|
| Gunnar Peterson | Cigital, Inc | 2007-02-28 | Fleshed out content to CAPEC schema from the original descriptions in "Exploiting Software" | | Sean Barnum | Cigital, Inc | 2007-03-09 | Review and revise | | Richard Struse | VOXEM, Inc | 2007-03-26 | Review and feedback leading to changes in Name and Description | | Sean Barnum | Cigital, Inc | 2007-04-13 | Modified pattern content according to review and feedback | | Amit Sethi | Cigital, Inc. | 2007-10-29 | Added extended Attack Execution Flow |
|
| Attack Pattern ID | Pattern Abstraction: Detailed 36 | | Typical Severity | High | | Description | Summary An attacker searches for and invokes Web Services APIs that the target system designers did not intend to be publicly available. If these APIs fail to authenticate requests the attacker may be able to invoke services and/or gain privileges they are not authorized for. Attack Execution Flow Discover a web service of interest, by exploring web service registry listings or by connecting on known port or some similar means Authenticate to the web service, if required, in order to explore it. Determine the exposed interfaces by querying the registry as well as probably sniffing to expose interfaces that are not explicitly listed.
| | Attack Prerequisites | The architecture under attack must publish or otherwise make available services, of some kind, that clients can attach to, either in an unauthenticated fashion, or having obtained an authentication token elsewhere.
The service need not be 'discoverable' but in the event it isn't, must have some way of being discovered by an attacker.
This might include listening on a well-known port. Ultimately, the likelihood of exploit depends on discoverability of the vulnerable service. | | Typical Likelihood of Exploit |
Medium
| | Methods of Attack | | | Examples-Instances | Description To an extent, Google services (such as Google Maps) are all well-known examples. Calling these services, or extending them for one's own (perhaps very different) purposes is as easy as knowing they exist. Their unencumbered public use, however, is a purposeful aspect of Google's business model. Most organizations, however, do not have the same business model. Organizations publishing services usually fall back on thoughts that Attackers "will not know services exist" and that "even if they did, they wouldn't be able to access them because they're not on the local LAN." Simple threat modeling exercises usually uncovers simple attack vectors that can invalidate these assumptions. | | Attacker Skill or Knowledge Required | Low: A number of web service digging tools are available for free that help discover exposed web services and their interfaces. In the event that a web service is not listed, the attacker does not need to know much more in addition to the format of web service messages that he can sniff/monitor for. | | Resources Required | No special resources are required in order to conduct these attacks. Web service digging tools may be helpful. | | Probing Techniques | Probing techniques should often follow normal means of identifying services. Attackers will simply have to execute code that sends the appropriate interrogating SOAP messages to suspected UDDI services (in web-services scenarios). Attackers will likely want to detect and query the organization's SOA Registry. Probing techniques become more difficult when the service isn't advertised, or doesn't leverage discovery frameworks such as UDDI or the WS-I standard. In these cases, sniffing network traffic may suffice, depending on whether or not discovery occurs over a protected channel. | | Solutions and Mitigations | Authenticating both services and their discovery, and protecting that authentication mechanism simply fixes the bulk of this problem. Protecting the authentication involves the standard means, including: 1) protecting the channel over which authentication occurs, 2) preventing the theft, forgery, or prediction of authentication credentials or the resultant tokens, or 3) subversion of password reset and the like. | | Attack Motivation-Consequences | - Information Leakage
- Privilege Escalation
| | Context Description | This pattern applies in contexts in which an organization makes services available, preferrably in a discoverable fashion.
Attackers can leverage web- or SOA-services available to them whether or not those services are 1) advertised by a directory, 2) themselves respond on well-known interfaces, or are 3) predictably indexed. Once identified and interfaced with, the Attacker is free to use the interface for all its spoils. In these cases, the system's designers have fallen prey to believing security by obscurity will work, or have not thought about a service's actual availability at all. Unlike more vanilla client-server interfaces, services usually publish an easy to use interface in XML (through UDDI) making reverse engineering services for use trivial. | | Related Weaknesses | | CWE-ID | Weakness Name | Weakness Relationship Type |
|---|
| 306 | No Authentication for Critical Function | Targeted | | 693 | Protection Mechanism Failure | Targeted | | 695 | Use of Low-Level Functionality | Targeted |
| | Relevant Security Requirements | Authenticate every request or message to a service Do not rely on lack of discoverability to protect privileged functions within the service | | Related Security Principles | - Never Assuming that Your Secrets Are Safe
- Complete Mediation
| | Related Guidelines | - Use Authorization Mechanisms Correctly
- Use Authentication Mechanisms, Where Appropriate, Correctly
| | Purpose | Penetration | | CIA Impact | | Confidentiality Impact | Integrity Impact | Availability Impact |
|---|
| High | Medium | Low |
| | Technical Context | | Architectural Paradigm | Framework | Platform | Language |
|---|
| SOA | All | All | All |
| | Source | | Submission(s) |
|---|
| Submitter | Organization | Date | Comment |
|---|
| John Steven | Cigital, Inc | 2007-02-10 | Initial core pattern content |
| Modification(s) |
|---|
| Modifier | Organization | Date | Comment |
|---|
| Chiradeep B. Chhaya | Cigital, Inc | 2007-02-23 | Fleshed out pattern with extra content | | Richard Struse | VOXEM, Inc | 2007-03-26 | Review and feedback leading to changes in Name and Description | | Sean Barnum | Cigital, Inc | 2007-04-13 | Modified pattern content according to review and feedback |
|
| Attack Pattern ID | Pattern Abstraction: Detailed 40 | | Typical Severity | Very High | | Description | Summary This attack exploits terminal devices that allow themselves to be written to by other users. The attacker sends command strings to the target terminal device hoping that the target user will hit enter and thereby execute the malicious command with their privileges. The attacker can send the results (such as copying /etc/passwd) to a known directory and collect once the attack has succeeded. | | Attack Prerequisites | User terminals must have a permissive access control such as world writeable that allows normal users to control data on other user's terminals. | | Typical Likelihood of Exploit |
High
| | Methods of Attack | | | Examples-Instances | Description Any system that allows other peers to write directly to its terminal process is vulnerable to this type of attack. If the terminals are available through being overprivileged (i.e. world-writable) or the attacker is an administrator, then a series of commands in this format can be used to echo commands out to victim terminals. "$echo -e "\033[30m\033\132" > /dev/ttyXX where XX is the tty number of the user under attack. This will paste the characters to another terminal (tty). Note this technique works only if the victim's tty is world writable (which it may not be). That is one reason why programs like write(1) and talk(1) in UNIX systems need to run setuid." [Hoglund and McGraw 04] If the victim continues to hit "enter" and execute the commands, there are an endless supply of vectors available to the attacker, copying files, open up network connections, ftp out to servers, and so on. | | Attacker Skill or Knowledge Required | Low | | Resources Required | Access to a terminal on the target network | | Solutions and Mitigations | Design: Ensure that terminals are only writeable by named owner user and/or administrator Design: Enforce principle of least privilege | | Attack Motivation-Consequences | - Privilege Escalation
- Information Leakage
- Run Arbitrary Code
| | Injection Vector | Payload delivered through standard user terminal. | | Payload | Command(s) executed directly on host, in other victim's terminal | | Activation Zone | Multi-user host | | Payload Activation Impact | Enables attacker to execute server side code with any commands that the program owner has privileges to. | | Related Weaknesses | | CWE-ID | Weakness Name | Weakness Relationship Type |
|---|
| 306 | No Authentication for Critical Function | Targeted | | 74 | Failure to Sanitize Data into a Different Plane (aka 'Injection') | Targeted |
| | Purpose | Exploitation | | CIA Impact | | Confidentiality Impact | Integrity Impact | Availability Impact |
|---|
| High | High | Low |
| | Technical Context | | Architectural Paradigm | Framework | Platform | Language |
|---|
| Mainframe | Other | UNIX-LINUX | All |
| | References | G. Hoglund and G. McGraw. Exploiting Software: How to Break Code. Addison-Wesley, February 2004. | | Source | | Submission(s) |
|---|
| Submitter | Organization | Date | Comment |
|---|
| G. Hoglund and G. McGraw. Exploiting Software: How to Break Code. Addison-Wesley, February 2004. | Cigital, Inc | 2007-01-01 | |
| Modification(s) |
|---|
| Modifier | Organization | Date | Comment |
|---|
| Gunnar Peterson | Cigital, Inc | 2007-02-28 | Fleshed out content to CAPEC schema from the original descriptions in "Exploiting Software" | | Sean Barnum | Cigital, Inc | 2007-03-09 | Review and revise | | Richard Struse | VOXEM, Inc | 2007-03-26 | Review and feedback leading to changes in Name, Description and Examples | | Sean Barnum | Cigital, Inc | 2007-04-13 | Modified pattern content according to review and feedback |
|
| Attack Pattern ID | Pattern Abstraction: Detailed 42 | | Typical Severity | High | | Description | Summary An attacker exploits a weakness in the MIME conversion routine to cause a buffer overflow and gain control over the mail server machine. The MIME system is designed to allow various different information formats to be interpreted and sent via e-mail. Attack points exist when data are converted to MIME compatible format and back. Attack Execution Flow Determine whether the mail server is unpatched and is potentially vulnerable to one of the known MIME conversion buffer overflows (e.g. Sendmail 8.8.3 and 8.8.4). Identify places in the system where vulnerable MIME conversion routines may be used. Send e-mail messages to the target system with specially crafted headers that trigger the buffer overflow and execute the shellcode.
| | Attack Prerequisites | The target system uses a mail server. Mail server vendor has not released a patch for the MIME conversion routine, the patch itself has a security hole or does not fix the original problem, or the patch has not been applied to the user's system. | | Typical Likelihood of Exploit |
High
| | Methods of Attack | | | Examples-Instances | Description Attack Example: Sendmail Overflow
A MIME conversion buffer overflow exists in Sendmail versions 8.8.3 and 8.8.4. Sendmail versions 8.8.3 and 8.8.4 are vulnerable to a buffer overflow in the MIME handling code. By sending a message with specially-crafted headers to the server, a remote attacker can overflow a buffer and execute arbitrary commands on the system with root privileges. Sendmail performs a 7 bit to 8 bit conversion on email messages. This vulnerability is due to the fact that insufficient bounds checking was performed while performing these conversions. This gave attacker an opportunity to overwrite the internal stack of sendmail while it is executing with root privileges. An attacker first probes the target system to figure out what mail server is used on the system and what version. An attacker could then test out the exploit at their leisure on their own machine running the same version of the mail server before using it in the wild. Related Vulnerability | | Attacker Skill or Knowledge Required | Low: It may be trivial to cause a DoS via this attack pattern High: Causing arbitrary code to execute on the target system. | | Probing Techniques | The first step is to figure what mail server (and what version) is running on the target system. | | Solutions and Mitigations | Stay up to date with third party vendor patches Disable the 7 to 8 bit conversion. This can be done by removing the F=9 flag from all Mailer specifications in the sendmail.cf file. For example, a sendmail.cf file with these changes applied should look similar to (depending on your system and configuration):
Mlocal, P=/usr/libexec/mail.local, F=lsDFMAw5:/|@qrmn, S=10/30, R=20/40, T=DNS/RFC822/X-Unix, A=mail -d $u Mprog, P=/bin/sh, F=lsDFMoqeu, S=10/30, R=20/40, D=$z:/, T=X-Unix, A=sh -c $u
This can be achieved for the "Mlocal" and "Mprog" Mailers by modifying the ".mc" file to include the following lines:
define(`LOCAL_MAILER_FLAGS', ifdef(`LOCAL_MAILER_FLAGS', `translit(LOCAL_MAILER_FLAGS, `9')', `rmn')) define(`LOCAL_SHELL_FLAGS', ifdef(`LOCAL_SHELL_FLAGS', `translit(LOCAL_SHELL_FLAGS, `9')', `eu'))
and then rebuilding the sendmail.cf file using m4(1). From "Exploiting Software", please see reference below. Use the sendmail restricted shell program (smrsh) Use mail.local | | Attack Motivation-Consequences | - Run Arbitrary Code
- Data Modification
- Denial of Service
- Privilege Escalation
| | Context Description | Content-Based Buffer Overflow
Data files are ubiquitous. They are used to store everything from documents to content media and critical computer settings. Every file has an inherent format that often encompasses special information such as file length, media type, and which fonts are boldface, all encoded directly in the data file. The attack vector against data files like these is simple: Mess up the data file and wait for some unsuspecting user to open it. Some kinds of files are strikingly simple and others have complex binary structures and numerical data embedded in them. Sometimes the simple act of opening a complex file in a hex editor and tweaking a few bytes is enough to cause the (unsuspecting) program that consumes the file to crash and burn. | | Injection Vector | The especially formated e-mail message whose body is put together in a way as to trigger the MIME conversion buffer overflow in the 7 to 8 bit MIME conversion function. | | Payload | The shellcode included as part of the e-mail message body that is executed on the target system with root privileges after the stack based buffer overflow in the 7 to 8 bit MIME conversion function is leveraged. | | Activation Zone | The function performing 7 to 8 bit MIME conversion. | | Related Weaknesses | | CWE-ID | Weakness Name | Weakness Relationship Type |
|---|
| 120 | Buffer Copy without Checking Size of Input ('Classic Buffer Overflow') | Targeted | | 119 | Failure to Constrain Operations within the Bounds of a Memory Buffer | Targeted | | 74 | Failure to Sanitize Data into a Different Plane (aka 'Injection') | Targeted | | 20 | Improper Input Validation | Secondary |
| | Related Vulnerabilities | | Vulnerability-ID | Vulnerability Description |
|---|
| CVE-1999-0047 | A MIME conversion buffer overflow exists in Sendmail versions 8.8.3 and 8.8.4. Sendmail versions 8.8.3 and 8.8.4 are vulnerable to a buffer overflow in the MIME handling code. By sending a message with specially-crafted headers to the server, a remote attacker can overflow a buffer and execute arbitrary commands on the system with root privileges.
Sendmail performs a 7 bit to 8 bit conversion on email messages. This vulnerability is due to the fact that insufficient bounds checking was performed while performing these conversions. This gave attacker an opportunity to overwrite the internal stack of sendmail while it is executing with root privileges. An attacker first probes the target system to figure out what mail server is used on the system and what version. An attacker could then test out the exploit at their leisure on their own machine running the same version of the mail server before using it in the wild. |
| | Related Security Principles | | | Purpose | Penetration Exploitation | | CIA Impact | | Confidentiality Impact | Integrity Impact | Availability Impact |
|---|
| High | High | High |
| | Technical Context | | Architectural Paradigm | Framework | Platform | Language |
|---|
| All | All | All | All |
| | References | G. Hoglund and G. McGraw. Exploiting Software: How to Break Code. Addison-Wesley, February 2004. CERT Advisory CA-1997-05, "MIME Conversion Buffer Overflow in Sendmail Versions 8.8.3 and 8.8.4". Available at: http://www.cert.org/advisories/CA-1997-05.html | | Source | | Submission(s) |
|---|
| Submitter | Organization | Date | Comment |
|---|
| G. Hoglund and G. McGraw. Exploiting Software: How to Break Code. Addison-Wesley, February 2004. | Cigital, Inc | 2007-03-01 | |
| Modification(s) |
|---|
| Modifier | Organization | Date | Comment |
|---|
| Eugene Lebanidze | Cigital, Inc | 2007-02-26 | Fleshed out content to CAPEC schema from the original descriptions in "Exploiting Software" | | Sean Barnum | Cigital, Inc | 2007-03-05 | Review and revise |
|
| Attack Pattern ID | Pattern Abstraction: Detailed 44 | | Typical Severity | Very High | | Description | Summary An attack of this type exploits a buffer overflow vulnerability in the handling of binary resources. Binary resources may includes music files like MP3, image files like JPEG files, and any other binary file. These attacks may pass unnoticed to the client machine through normal usage of files, such as a browser loading a seemingly innocent JPEG file. This can allow the attacker access to the execution stack and execute arbitrary code in the target process. This attack pattern is a variant of standard buffer overflow attacks using an unexpected vector (binary files) to wrap its attack and open up a new attack vector. The attacker is required to either directly serve the binary content to the victim, or place it in a locale like a MP3 sharing application, for the victim to download. The attacker then is notified upon the download or otherwise locates the vulnerability opened up by the buffer overflow. | | Attack Prerequisites | Target software processes binary resource files. Target software contains a buffer overflow vulnerability reachable through input from a user-controllable binary resource file. | | Typical Likelihood of Exploit |
High
| | Methods of Attack | - Modification of Resources
| | Examples-Instances | Description Binary files like music and video files are appended with additional data to cause buffer overflow on target systems. Because these files may be filled with otherwise popular content, the attacker has an excellent vector for wide distribution. There have been numerous cases, for example of malicious screen savers for sports teams that are distributed on the event of the team winning a championship. | | Attacker Skill or Knowledge Required | Medium: to modify file, deceive client into downloading, locate and exploit remote stack or heap vulnerability | | Solutions and Mitigations | Perform appropriate bounds checking on all buffers. Design: Enforce principle of least privilege Design: Static code analysis Implementation: Execute program in less trusted process space environment, do not allow lower integrity processes to write to higher integrity processes Implementation: Keep software patched to ensure that known vulnerabilities are not available for attackers to target on host. | | Attack Motivation-Consequences | - Denial of Service
- Run Arbitrary Code
| | Context Description | "Attack Pattern: Overflow Binary Resource File The attacker modifies a resource file, such as sound, video, graphic, or font file. Sometimes simply editing the target resource file in a hex editor is possible. The attacker modifies headers and structure data that indicate the length of strings, and so forth."
[Hoglund and McGraw 04] | | Related Weaknesses | | CWE-ID | Weakness Name | Weakness Relationship Type |
|---|
| 119 | Failure to Constrain Operations within the Bounds of a Memory Buffer | Targeted | | 697 | Insufficient Comparison | Targeted | | 713 | OWASP Top Ten 2007 Category A2 - Injection Flaws | Targeted |
| | Related Attack Patterns | | ID | Name | Relationship Type | Relationship Description |
|---|
| 23 | File System Function Injection, Content Based | Similar | | | 35 | Leverage Executable Code in Nonexecutable Files | Similar | |
| | Purpose | Penetration Exploitation | | CIA Impact | | Confidentiality Impact | Integrity Impact | Availability Impact |
|---|
| High | High | High |
| | Technical Context | | Architectural Paradigm | Framework | Platform | Language |
|---|
| All | All | All | All |
| | References | G. Hoglund and G. McGraw. Exploiting Software: How to Break Code. Addison-Wesley, February 2004. | | Source | | Submission(s) |
|---|
| Submitter | Organization | Date | Comment |
|---|
| G. Hoglund and G. McGraw. Exploiting Software: How to Break Code. Addison-Wesley, February 2004. | Cigital, Inc | 2007-01-01 | |
| Modification(s) |
|---|
| Modifier | Organization | Date | Comment |
|---|
| Gunnar Peterson | Cigital, Inc | 2007-02-28 | Fleshed out content to CAPEC schema from the original descriptions in "Exploiting Software" | | Sean Barnum | Cigital, Inc | 2007-03-09 | Review and revise | | Richard Struse | VOXEM, Inc | 2007-03-26 | Review and feedback leading to changes in Related Attack Patterns | | Sean Barnum | Cigital, Inc | 2007-04-13 | Modified pattern content according to review and feedback |
|
| Attack Pattern ID | Pattern Abstraction: Detailed 45 | | Typical Severity | High | | Description | Summary This type of attack leverages the use of symbolic links to cause buffer overflows. An attacker can try to create or manipulate a symbolic link file such that its contents result in out of bounds data. When the target software processes the symbolic link file, it could potentially overflow internal buffers with insufficient bounds checking. Attack Execution Flow The attacker creates or modifies a symbolic link pointing to a resources (e.g., file, directory). The content of the symbolic link file includes out-of-bounds (e.g. excessive length) data. The target host consumes the data pointed to by the symbolic link file. The target host may either intentionally expect to read a symbolic link or it may be fooled by the replacement of the original resource and read the attacker's symbolic link. While consuming the data, the target host does not check for buffer boundary which can lead to a buffer overflow. If the content of the data is controlled by the attacker, this is an avenue for remote code execution.
| | Attack Prerequisites | The attacker can create symbolic link on the target host. The target host does not perform correct boundary checking while consuming data from a ressources. | | Typical Likelihood of Exploit |
High
| | Methods of Attack | - Injection
- Modification of Resources
| | Examples-Instances | Description Attack Example: Overflow with Symbolic Links in EFTP Server
The EFTP server has a buffer overflow that can be exploited if an attacker uploads a .lnk (link) file that contains more than 1,744 bytes. This is a classic example of an indirect buffer overflow. First the attacker uploads some content (the link file) and then the attacker causes the client consuming the data to be exploited. In this example, the ls command is exploited to compromise the server software. | | Attacker Skill or Knowledge Required | Low : An attacker can simply overflow a buffer by inserting a long string into an attacker-modifiable injection vector. The result can be a DoS. High : Exploiting a buffer overflow to inject malicious code into the stack of a software system or even the heap can require a higher skill level. | | Probing Techniques | The attacker will look for temporary files in the world readable directories. Those temporary files are often created and read by the system. The attacker will look for Symbolic link or link target file that she can overide. | | Indicators-Warnings of Attack | An attacker creating or modifying Symbolic links is a potential signal of attack in progress. An attacker deleting temporary files can also be a sign that the attacker is trying to replace legitimate resources with malicious ones. | | Solutions and Mitigations | Pay attention to the fact that the ressource you read from can be a replaced by a Symbolic link. You can do a Symlink check before reading the file and decide that this is not a legitimate way of accessing the resource. Because Symlink can be modified by an attacker, make sure that the ones you read are located in protected directories. Pay attention to the resource pointed to by your symlink links (See attack pattern named "Forced Symlink race"), they can be replaced by malicious resources. Always check the size of the input data before copying to a buffer. Use a language or compiler that performs automatic bounds checking. Use an abstraction library to abstract away risky APIs. Not a complete solution. Compiler-based canary mechanisms such as StackGuard, ProPolice and the Microsoft Visual Studio /GS flag. Unless this provides automatic bounds checking, it is not a complete solution. Use OS-level preventative functionality. Not a complete solution. | | Attack Motivation-Consequences | - Denial of Service
- Run Arbitrary Code
- Information Leakage
- Data Modification
| | Context Description | Content-Based Buffer Overflow
Data files are ubiquitous. They are used to store everything from documents to content media and critical computer settings. Every file has an inherent format that often encompasses special information such as file length, media type, and which fonts are boldface, all encoded directly in the data file. The attack vector against data files like these is simple: Mess up the data file and wait for some unsuspecting user to open it. Some kinds of files are strikingly simple and others have complex binary structures and numerical data embedded in them. Sometimes the simple act of opening a complex file in a hex editor and tweaking a few bytes is enough to cause the (unsuspecting) program that consumes the file to crash and burn. What's really interesting from an attacker's point of view is formatting data file-embedded poison pills in such a way that virus code is activated. A great example of this involved the Winamp program in which an overly long IDv3 tag would cause a buffer overflow. In the header of an MP3 file, there is a location where a normal text string can be placed. This is called the IDv3 tag, and if an overly long tag were to be supplied, Winamp would suffer a buffer overflow. This could be used by an attacker to construct malicious music files that attack the computer once they are opened in Winamp. Access right to the symbolic link: When a symlink is created there are no rights associated with it (this why you read them with rights lrwxrwxrwx). So everybody can modify them even if the owner of the Symlink is root and if the user changing the Symbolic link has no right on the link target file. The relevant rights are on the linked target file. To prevent someone from modifying the symlink in the first place, the directory containing it should have limited access rights. | | Injection Vector | The resource pointed to by the Symbolic link (e.g., file, directory, etc.) | | Payload | The buffer overrun by the attacker. | | Activation Zone | When the function returns control to the main program, it jumps to the return address portion of the stack frame. Unfortunately that return address may have been overwritten by the overflowed buffer and the address may contain a call to a privileged command or to a malicious code. | | Payload Activation Impact | The most common is remote code execution. | | Related Weaknesses | | CWE-ID | Weakness Name | Weakness Relationship Type |
|---|
| 120 | Buffer Copy without Checking Size of Input ('Classic Buffer Overflow') | Targeted | | 285 | Improper Access Control (Authorization) | Secondary | | 302 | Authentication Bypass by Assumed-Immutable Data | Targeted | | 118 | Improper Access of Indexable Resource (aka 'Range Error') | Targeted | | 119 | Failure to Constrain Operations within the Bounds of a Memory Buffer | Targeted | | 74 | Failure to Sanitize Data into a Different Plane (aka 'Injection') | Targeted | | 20 | Improper Input Validation | Targeted | | 680 | Integer Overflow to Buffer Overflow | Targeted | | 697 | Insufficient Comparison | Targeted |
| | Related Security Principles | | | Purpose | Penetration Exploitation | | CIA Impact | | Confidentiality Impact | Integrity Impact | Availability Impact |
|---|
| High | High | High |
| | Technical Context | | Architectural Paradigm | Framework | Platform | Language |
|---|
| All | All | All | All |
| | References | G. Hoglund and G. McGraw. Exploiting Software: How to Break Code. Addison-Wesley, February 2004. CWE - Buffer Errors | | Source | | Submission(s) |
|---|
| Submitter | Organization | Date | Comment |
|---|
| G. Hoglund and G. McGraw. Exploiting Software: How to Break Code. Addison-Wesley, February 2004. | Cigital, Inc | 2007-03-01 | |
| Modification(s) |
|---|
| Modifier | Organization | Date | Comment |
|---|
| Eric Dalci | Cigital, Inc | 2007-02-13 | Fleshed out content to CAPEC schema from the original descriptions in "Exploiting Software" | | Sean Barnum | Cigital, Inc | 2007-03-05 | Review and revise | | Richard Struse | VOXEM, Inc | 2007-03-26 | Review and feedback leading to changes in Name and Description | | Sean Barnum | Cigital, Inc | 2007-04-13 | Modified pattern content according to review and feedback |
|
| Attack Pattern ID | Pattern Abstraction: Detailed 46 | | Typical Severity | High | | Description | Summary This type of attack leverages the use of tags or variables from a formatted configuration data to cause buffer overflow. The attacker crafts a malicious HTML page or configuration file that includes oversized strings, thus causing an overflow. Attack Execution Flow The attacker modifies a tag or variable from a formatted configuration data. For instance she changes it to an oversized string. The target program consumes the data modified by the attacker without prior boundary checking. As a consequence, a buffer overflow occurs and at worst remote code execution may follow.
| | Attack Prerequisites | The target program consumes user-controllable data in the form of tags or variables. The target program does not perform sufficient boundary checking. | | Typical Likelihood of Exploit |
High
| | Methods of Attack | | | Examples-Instances | Description Attack Example: Overflow Variables and Tags in MidiPlug
A buffer overflow vulnerability exists in the Yamaha MidiPlug that can be accessed via a Text variable found in an EMBED tag. Related Vulnerability Description Attack Example: Overflow Variables and Tags in Exim
A buffer overflow in Exim allows local users to gain root privileges by providing a long :include: option in a .forward file. Related Vulnerability | | Attacker Skill or Knowledge Required | Low : An attacker can simply overflow a buffer by inserting a long string into an attacker-modifiable injection vector. The result can be a DoS. High : Exploiting a buffer overflow to inject malicious code into the stack of a software system or even the heap can require a higher skill level. | | Probing Techniques | An attacker can modify the variables and tag exposed by the target program. An attacker can automate the probing by input injection with script or automated tools. | | Solutions and Mitigations | Use a language or compiler that performs automatic bounds checking. Use an abstraction library to abstract away risky APIs. Not a complete solution. Compiler-based canary mechanisms such as StackGuard, ProPolice and the Microsoft Visual Studio /GS flag. Unless this provides automatic bounds checking, it is not a complete solution. Use OS-level preventative functionality. Not a complete solution. Do not trust input data from user. Validate all user input. | | Attack Motivation-Consequences | - Denial of Service
- Run Arbitrary Code
- Information Leakage
- Data Modification
| | Context Description | Content-Based Buffer Overflow
Data files are ubiquitous. They are used to store everything from documents to content media and critical computer settings. Every file has an inherent format that often encompasses special information such as file length, media type, and which fonts are boldface, all encoded directly in the data file. The attack vector against data files like these is simple: Mess up the data file and wait for some unsuspecting user to open it. Some kinds of files are strikingly simple and others have complex binary structures and numerical data embedded in them. Sometimes the simple act of opening a complex file in a hex editor and tweaking a few bytes is enough to cause the (unsuspecting) program that consumes the file to crash and burn. What's really interesting from an attacker's point of view is formatting data file-embedded poison pills in such a way that virus code is activated. A great example of this involved the Winamp program in which an overly long IDv3 tag would cause a buffer overflow. In the header of an MP3 file, there is a location where a normal text string can be placed. This is called the IDv3 tag, and if an overly long tag were to be supplied, Winamp would suffer a buffer overflow. This could be used by an attacker to construct malicious music files that attack the computer once they are opened in Winamp. | | Injection Vector | The variable or tag exposed to the user. | | Payload | The new value of the variable or tag (could be an oversized string). | | Activation Zone | When the function returns control to the main program, it jumps to the return address portion of the stack frame. Unfortunately that return address may have been overwritten by the overflowed buffer and the address may contain a call to a privileged command or to a malicious code. | | Payload Activation Impact | The most common is remote code execution. | | Related Weaknesses | | CWE-ID | Weakness Name | Weakness Relationship Type |
|---|
| 120 | Buffer Copy without Checking Size of Input ('Classic Buffer Overflow') | Targeted | | 118 | Improper Access of Indexable Resource (aka 'Range Error') | Targeted | | 119 | Failure to Constrain Operations within the Bounds of a Memory Buffer | Targeted | | 74 | Failure to Sanitize Data into a Different Plane (aka 'Injection') | Targeted | | 20 | Improper Input Validation | Targeted | | 680 | Integer Overflow to Buffer Overflow | Targeted | | 733 | Compiler Optimization Removal or Modification of Security-critical Code | Secondary | | 697 | Insufficient Comparison | Targeted |
| | Related Attack Patterns | | ID | Name | Relationship Type | Relationship Description |
|---|
| 100 | Overflow Buffers | More Detailed | | | 8 | Buffer Overflow in an API Call | Similar | | | 10 | Buffer Overflow via Environment Variables | Similar | |
| | Related Security Principles | | | Purpose | Penetration Exploitation | | CIA Impact | | Confidentiality Impact | Integrity Impact | Availability Impact |
|---|
| High | High | High |
| | Technical Context | | Architectural Paradigm | Framework | Platform | Language |
|---|
| All | All | All | All |
| | References | G. Hoglund and G. McGraw. Exploiting Software: How to Break Code. Addison-Wesley, February 2004. CWE - Buffer Errors | | Source | | Submission(s) |
|---|
| Submitter | Organization | Date | Comment |
|---|
| G. Hoglund and G. McGraw. Exploiting Software: How to Break Code. Addison-Wesley, February 2004. | Cigital, Inc | 2007-03-01 | |
| Modification(s) |
|---|
| Modifier | Organization | Date | Comment |
|---|
| Eric Dalci | Cigital, Inc | 2007-02-13 | Fleshed out content to CAPEC schema from the original descriptions in "Exploiting Software" | | Sean Barnum | Cigital, Inc | 2007-03-05 | Review and revise | | Richard Struse | VOXEM, Inc | 2007-03-26 | Review and feedback leading to changes in Related Attack Patterns | | Sean Barnum | Cigital, Inc | 2007-04-13 | Modified pattern content according to review and feedback |
|
| Attack Pattern ID | Pattern Abstraction: Detailed 47 | | Typical Severity | High | | Description | Summary In this attack, the target software is given input that the attacker knows will be modified and expanded in size during processing. This attack relies on the target software failing to anticipate that the expanded data may exceed some internal limit, thereby creating a buffer overflow. Attack Execution Flow Consider parts of the program where user supplied data may be expanded by the program. Use a disassembler and other reverse engineering tools to guide the search. Find a place where a buffer overflow occurs due to the fact that the new expanded size of the string is not correctly accounted for by the program. This may happen perhaps when the string is copied to another buffer that is big enough to hold the original, but not the expanded string. This may create an opportunity for planting the payload and redirecting program execution to the shellcode. Write the buffer overflow exploit. To be exploitable, the "spill over" amount (e.g. the difference between the expanded string length and the original string length before it was expanded) needs to be sufficient to allow the overflow of the stack return pointer (in the case of a stack overflow), without causing a stack corruption that would crash the program before it gets to execute the shellcode. Heap overflow will be more difficult and will require the attacker to get more lucky, by perhaps getting a chance to overwrite some of the accounting information stored as part of using malloc().
| | Attack Prerequisites | The program expands one of the parameters passed to a function with input controlled by the user, but a later function making use of the expanded parameter erroneously considers the original, not the expanded size of the parameter. The expanded parameter is used in the context where buffer overflow may becomes possible due to the incorrect understanding of the parameter size (i.e. thinking that it is smaller than it really is). | | Typical Likelihood of Exploit |
Medium
| | Methods of Attack | | | Examples-Instances | Description Attack Example: FTP glob()
The glob() function in FTP servers has been susceptible to attack as a result of incorrect resizing. This is an ftpd glob() Expansion LIST Heap Overflow Vulnerability. ftp daemon contains a heap-based buffer overflow condition. The overflow occurs when the LIST command is issued with an argument that expands into an oversized string after being processed by glob(). This buffer overflow occurs in memory that is dynamically allocated. It may be possible for attackers to exploit this vulnerability and execute arbitrary code on the affected host. To exploit this, the attacker must be able to create directories on the target host. The glob() function is used to expand short-hand notation into complete file names. By sending to the FTP server a request containing a tilde (~) and other wildcard characters in the pathname string, a remote attacker can overflow a buffer and execute arbitrary code on the FTP server to gain root privileges. Once the request is processed, the glob() function expands the user input, which could exceed the expected length. In order to exploit this vulnerability, the attacker must be able to create directories on the FTP server. From G. Hoglund and G. McGraw. Exploiting Software: How to Break Code. Addison-Wesley, February 2004. Related Vulnerability Description Buffer overflow in the glob implementation in libc in NetBSD-current before 20050914, and NetBSD 2.* and 3.* before 20061203, as used by the FTP daemon, allows remote authenticated users to execute arbitrary code via a long pathname that results from path expansion. The limit computation of an internal buffer was done incorrectly. The size of the buffer in byte was used as element count, even though the elements of the buffer are 2 bytes long. Long expanded path names would therefore overflow the buffer. Related Vulnerability | | Attacker Skill or Knowledge Required | High: Finding this particular buffer overflow may not be trivial. Also, stack and especially heap based buffer overflows require a lot of knowledge if the intended goal is aribtrary code execution. Not only that the attacker needs to write the shell code to accomplish his or her goals, but the attacker also needs to find a way to get the program execution to jump to the planted shellcode. There also needs to be sufficient room for the payload. So not every buffer overflow will be exploitable, even by a skilled attacker. | | Resources Required | Access to the program source or binary. If the program is only available in binary then a disassembler and other reverse engineering tools will be helpful. | | Solutions and Mitigations | Ensure that when parameter expansion happens in the code that the assumptions used to determine the resulting size of the parameter are accurate and that the new size of the parameter is visible to the whole system | | Attack Motivation-Consequences | - Privilege Escalation
- Privilege Escalation
- Denial of Service
- Data Modification
| | Context Description | The Multiple Operation Problem
Whenever data are manipulated by a function, the function should track exactly what it's doing to the data. This is straightforward when only one function is "munging" data. But when multiple operations are working on the same data, keeping track of the effects of each operation gets much harder. Incorrect tracking leads to big problems. This is especially true if the operation changes a string somehow. There are a number of common operations on strings that will change the size of the string. The problem we're discussing occurs if the code performing the conversion does not resize the buffer that the string lives in. | | Related Weaknesses | | CWE-ID | Weakness Name | Weakness Relationship Type |
|---|
| 120 | Buffer Copy without Checking Size of Input ('Classic Buffer Overflow') | Targeted | | 119 | Failure to Constrain Operations within the Bounds of a Memory Buffer | Targeted | | 118 | Improper Access of Indexable Resource (aka 'Range Error') | Targeted | | 130 | Failure to Handle Length Parameter Inconsistency | Targeted | | 131 | Incorrect Calculation of Buffer Size | Targeted | | 74 | Failure to Sanitize Data into a Different Plane (aka 'Injection') | Targeted | | 20 | Improper Input Validation | Secondary | | 680 | Integer Overflow to Buffer Overflow | Targeted | | 697 | Insufficient Comparison | Targeted |
| | Related Attack Patterns | | ID | Name | Relationship Type | Relationship Description |
|---|
| 100 | Overflow Buffers | More Detailed | |
| | Purpose | Penetration Exploitation | | CIA Impact | | Confidentiality Impact | Integrity Impact | Availability Impact |
|---|
| High | High | High |
| | Technical Context | | Architectural Paradigm | Framework | Platform | Language |
|---|
| All | All | All | All |
| | References | G. Hoglund and G. McGraw. Exploiting Software: How to Break Code. | | Source | | Submission(s) |
|---|
| Submitter | Organization | Date | Comment |
|---|
| G. Hoglund and G. McGraw. Exploiting Software: How to Break Code. Addison-Wesley, February 2004. | Cigital, Inc | 2007-03-01 | |
| Modification(s) |
|---|
| Modifier | Organization | Date | Comment |
|---|
| Eugene Lebanidze | Cigital, Inc | 2007-02-26 | Fleshed out content to CAPEC schema from the original descriptions in "Exploiting Software" | | Sean Barnum | Cigital, Inc | 2007-03-05 | Review and revise | | Richard Struse | VOXEM, Inc | 2007-03-26 | Review and feedback leading to changes in Name, Description and Related Attack Patterns | | Sean Barnum | Cigital, Inc | 2007-04-13 | Modified pattern content according to review and feedback |
|
| Attack Pattern ID | Pattern Abstraction: Detailed 48 | | Typical Severity | High | | Description | Summary This attack relies on client side code to access local files and resources instead of URLs. When the client browser is expecting a URL string, but instead receives a request for a local file, that execution is likely to occur in the browser process space with the browser's authority to local files. The attacker can send the results of this request to the local files out to a site that they control. This attack may be used to steal sensitive authentication data (either local or remote), or to gain system profile information to launch further attacks. | | Attack Prerequisites | The victim's software must not differentiate between the location and type of reference passed the client software, e.g. browser | | Typical Likelihood of Exploit |
High
| | Methods of Attack | - API Abuse
- Modification of Resources
- Protocol Manipulation
| | Examples-Instances | Description J2EE applications frequently use .properties files to store configuration information including JDBC connections, LDAP connection strings, proxy information, system passwords and other system metadata that is valuable to attackers looking to probe the system or bypass policy enforcement points. When these files are stored in publicly accessible directories and are allowed to be read by the public user, then an attacker can list the directory identify a .properties file and simply load its contents in the browser listing its contents. A standard Hibernate properties file contains hibernate.connection.driver_class = org.postgresql.Driver hibernate.connection.url = jdbc:postgresql://localhost/mydatabase hibernate.connection.username = username hibernate.connection.password = password hibernate.c3p0.min_size=5 hibernate.c3p0.max_size=20 Even if the attacker cannot write this file, there is plenty of information to leverage to gain further access. | | Attacker Skill or Knowledge Required | Medium: attacker identifies known local files to exploit | | Solutions and Mitigations | Implementation: Ensure all content that is delivered to client is sanitized against an acceptable content specification. Implementation: Ensure all configuration files and resource are either removed or protected when promoting code into production. Design: Use browser technologies that do not allow client side scripting. Implementation: Perform input validation for all remote content. Implementation: Perform output validation for all remote content. Implementation: Disable scripting languages such as Javascript in browser | | Attack Motivation-Consequences | - Information Leakage
- Data Modification
| | Context Description | "Attack Pattern: Passing Local Filenames to Functions That Expect a URL Use local filenames with functions that expect to consume a URL. Find interesting connections."
[Hoglund and McGraw 04] | | Related Weaknesses | | CWE-ID | Weakness Name | Weakness Relationship Type |
|---|
| 241 | Failure to Handle Wrong Data Type | Targeted | | 706 | Use of Incorrectly-Resolved Name or Reference | Targeted |
| | Purpose | Exploitation | | CIA Impact | | Confidentiality Impact | Integrity Impact | Availability Impact |
|---|
| High | High | Low |
| | Technical Context | | Architectural Paradigm | Framework | Platform | Language |
|---|
| All | All | All | All |
| | References | G. Hoglund and G. McGraw. Exploiting Software: How to Break Code. Addison-Wesley, February 2004. | | Source | | Submission(s) |
|---|
| Submitter | Organization | Date | Comment |
|---|
| G. Hoglund and G. McGraw. Exploiting Software: How to Break Code. Addison-Wesley, February 2004. | Cigital, Inc | 2007-01-01 | |
| Modification(s) |
|---|
| Modifier | Organization | Date | Comment |
|---|
| Gunnar Peterson | Cigital, Inc | 2007-02-28 | Fleshed out content to CAPEC schema from the original descriptions in "Exploiting Software" | | Sean Barnum | Cigital, Inc | 2007-03-09 | Review and revise |
|
| Attack Pattern ID | Pattern Abstraction: Detailed 52 | | Typical Severity | High | | Description | Summary An attacker embeds one or more null bytes in input to the target software. This attack relies on the usage of a null-valued byte as a string terminator in many environments. The goal is for certain components of the target software to stop processing the input when it encounters the null byte(s). Attack Execution Flow Identify a place in the program where user input may be used to escalate privileges by for instance accessing unauthorized file system resources through directory browsing. An attacker realizes that there is a postfix data that gets in the way of getting to the desired resources An attacker then ads a postfix NULL terminator to the supplied input in order to "swallow" the postfixed data when the insertion is taking place. With the postfix data that got in the way of the attack gone, the doors are opened for accessing the desired resources.
| | Attack Prerequisites | The program does not properly handle postfix NULL terminators | | Typical Likelihood of Exploit |
High
| | Methods of Attack | - Injection
- Modification of Resources
- API Abuse
| | Examples-Instances | Description Directory Browsing
Assume a Web application allows a user to access a set of reports. The path to the reports directory may be something like web/username/reports. If the username is supplied via a hidden field, an attacker could insert a bogus username such as ../../../../../WINDOWS. If the attacker needs to remove the trailing string /reports, then he can simply insert enough characters so the string is truncated. Alternatively the attacker might apply the postfix NULL character (%00) to determine whether this terminates the string. Different forms of NULL to think about include PATH%00 PATH[0x00] PATH[alternate representation of NULL character] <script></script>%00 Description Exploitation of a buffer overflow vulnerability in the ActiveX component packaged with Adobe Systems Inc.'s Acrobat/Acrobat Reader allows remote attackers to execute arbitrary code.
The problem specifically exists upon retrieving a link of the following form: GET /any_existing_dir/any_existing_pdf.pdf%00[long string] HTTP/1.1 Where [long string] is a malicious crafted long string containing acceptable URI characters. The request must be made to a web server that truncates the request at the null byte (%00), otherwise an invalid file name is specified and a "file not found" page will be returned. Example web servers that truncate the requested URI include Microsoft IIS and Netscape Enterprise. Though the requested URI is truncated for the purposes of locating the file the long string is still passed to the Adobe ActiveX component responsible for rendering the page. This in turn triggers a buffer overflow within RTLHeapFree() allowing for an attacker to overwrite an arbitrary word in memory. The responsible instructions from RTLHeapFree() are shown here: 0x77F83AE5 MOV EAX,[EDI+8] 0x77F83AE8 MOV ECX,[EDI+C] ... 0x77F83AED MOV [ECX],EAX The register EDI contains a pointer to a user-supplied string. The attacker therefore has control over both the ECX and EAX registers used in the shown MOV instruction. Successful exploitation allows remote attackers to utilize the arbitrary word overwrite to redirect the flow of control and eventually take control of the affected system. Code execution will occur under the context of the user that instantiated the vulnerable version of Adobe Acrobat. An attacker does not need to establish a malicious web site as exploitation can occur by adding malicious content to the end of any embedded link and referencing any Microsoft IIS or Netscape Enterprise web server. Clicking on a direct malicious link is also not required as it may be embedded within an IMAGE tag, an IFRAME or an auto-loading script. Successful exploitation requires that a payload be written such that certain areas of the input are URI acceptable. This includes initial injected instructions as well as certain overwritten addresses. This increases the complexity of successful exploitation. While not trivial, exploitation is definitely plausible [iDefense]. Related Vulnerability Description Consider the following PHP script:
$whatever = addslashes($_REQUEST['whatever']); include("/path/to/program/" . $whatever . "/header.htm"); A malicious attacker might open the following URL, disclosing the boot.ini file: http://localhost/phpscript.php?whatever=../../../../boot.ini%00 | | Attacker Skill or Knowledge Required | Medium: Directory traversal High: Execution of arbitrary code | | Solutions and Mitigations | Properly handle the NULL characters supplied as part of user input prior to doing anything with the data. | | Attack Motivation-Consequences | - Data Modification
- Information Leakage
- Privilege Escalation
- Run Arbitrary Code
| | Related Weaknesses | | CWE-ID | Weakness Name | Weakness Relationship Type |
|---|
| 158 | Failure to Sanitize Null Byte or NUL Character | Targeted | | 172 | Encoding Error | Targeted | | 173 | Failure to Handle Alternate Encoding | Targeted | | 171 | Cleansing, Canonicalization, and Comparison Errors | Targeted | | 74 | Failure to Sanitize Data into a Different Plane (aka 'Injection') | Targeted | | 20 | Improper Input Validation | Targeted | | 697 | Insufficient Comparison | Targeted | | 707 | Failure to Enforce that Messages or Data are Well-Formed | Targeted |
| | Related Security Principles | | | Purpose | Penetration Exploitation | | CIA Impact | | Confidentiality Impact | Integrity Impact | Availability Impact |
|---|
| High | High | High |
| | Technical Context | | Architectural Paradigm | Framework | Platform | Language |
|---|
| All | All | All | All |
| | References | G. Hoglund and G. McGraw. Exploiting Software: How to Break Code. Addison-Wesley, February 2004. iDefense Labs Public Advisory: Adobe Acrobat/Acrobat Reader ActiveX Control Buffer Overflow Vulnerability
Available at: http://labs.idefense.com/intelligence/vulnerabilities/display.php?id=126 Bugtraq mailing list archive: PHP Input Validation Vulnerabilities
Available at: http://msgs.securepoint.com/bugtraq/ | | Source | | Submission(s) |
|---|
| Submitter | Organization | Date | Comment |
|---|
| G. Hoglund and G. McGraw. Exploiting Software: How to Break Code. Addison-Wesley, February 2004. | Cigital, Inc | 2007-03-01 | |
| Modification(s) |
|---|
| Modifier | Organization | Date | Comment |
|---|
| Eugene Lebanidze | Cigital, Inc | 2007-02-26 | Fleshed out content to CAPEC schema from the original descriptions in "Exploiting Software" | | Sean Barnum | Cigital, Inc | 2007-03-05 | Review and revise | | Richard Struse | VOXEM, Inc | 2007-03-26 | Review and feedback leading to changes in Name, Description and Context Description | | Sean Barnum | Cigital, Inc | 2007-04-13 | Modified pattern content according to review and feedback |
|
| Attack Pattern ID | Pattern Abstraction: Detailed 53 | | Typical Severity | High | | Description | Summary If a string is passed through a filter of some kind, then a terminal NULL may not be valid. Using alternate representation of NULL allows an attacker to embed the NULL midstring while postfixing the proper data so that the filter is avoided. One example is a filter that looks for a trailing slash character. If a string insertion is possible, but the slash must exist, an alternate encoding of NULL in midstring may be used. Attack Execution Flow An attacker first probes to figure out what restrictions on input are placed by filter, such as a specific characters on the end of the URL. The attacker then injects a string of their choosing with a null terminator (using an alternate encoding such as %00), followed by a backslash (%5C), followed by some additional characters that are required to keep the filter happy The malicious string then passes through the filter and passed to the underlying API. Everything after the null terminator is ignored. This may give an attacker the opportunity to access file system resources to which they should not have access and do other things.
Some popular forms in which this takes place:
PATH%00%5C
PATH[0x00][0x5C]
PATH[alternate encoding of the NULL][additional characters required to pass filter]
| | Attack Prerequisites | Null terminators are not properly handled by the filter. | | Typical Likelihood of Exploit |
High
| | Methods of Attack | | | Examples-Instances | Description A rather simple injection is possible in a URL:
http://getAccessHostname/sekbin/ helpwin.gas.bat?mode=&draw=x&file=x&module=&locale=[insert relative path here] [%00][%5C]&chapter= This attack has appeared with regularity in the wild. There are many variations of this kind of attack. Spending a short amount of time injecting against Web applications will usually result in a new exploit being discovered. | | Attacker Skill or Knowledge Required | Medium: An attacker needs to understand alternate encodings, what the filter looks for and the data format acceptable to the target API | | Probing Techniques | Test the program with various inputs and observe the behavior of the filter. Overtime it should be possible to understand what the filter is expecting. | | Indicators-Warnings of Attack | Null characters are observed by the filter. The filter needs to be able to understand various encodings of the Null character, or only canonical data should be passed to it. | | Solutions and Mitigations | Properly handle Null characters. Make sure canonicalization is properly applied. Do not pass Null characters to the underlying APIs. Assume all input is malicious. Create a white list that defines all valid input to the software system based on the requirements specifications. Input that does not match against the white list should not be permitted to enter into the system. | | Attack Motivation-Consequences | - Data Modification
- Information Leakage
- Privilege Escalation
| | Context Description | hether this terminates the string.
Once again, some popular forms this takes include PATH%00%5C PATH[0x00][0x5C] PATH[alternate encoding of the NULL][additional characters required to pass filter] From G. Hoglund and G. McGraw. Exploiting Software: How to Break Code. Addison-Wesley, February 2004. | | Related Weaknesses | | CWE-ID | Weakness Name | Weakness Relationship Type |
|---|
| 158 | Failure to Sanitize Null Byte or NUL Character | Targeted | | 172 | Encoding Error | Targeted | | 173 | Failure to Handle Alternate Encoding | Targeted | | 171 | Cleansing, Canonicalization, and Comparison Errors | Targeted | | 74 | Failure to Sanitize Data into a Different Plane (aka 'Injection') | Targeted | | 20 | Improper Input Validation | Targeted | | 697 | Insufficient Comparison | Targeted | | 707 | Failure to Enforce that Messages or Data are Well-Formed | Targeted |
| | Related Attack Patterns | | ID | Name | Relationship Type | Relationship Description |
|---|
| 52 | Embedding NULL Bytes | More Detailed | |
| | Related Security Principles | | | Purpose | Penetration | | CIA Impact | | Confidentiality Impact | Integrity Impact | Availability Impact |
|---|
| High | High | Low |
| | Technical Context | | Architectural Paradigm | Framework | Platform | Language |
|---|
| All | All | All | All |
| | References | G. Hoglund and G. McGraw. Exploiting Software: How to Break Code. Addison-Wesley, February 2004. | | Source | | Submission(s) |
|---|
| Submitter | Organization | Date | Comment |
|---|
| G. Hoglund and G. McGraw. Exploiting Software: How to Break Code. Addison-Wesley, February 2004. | Cigital, Inc | 2007-03-01 | |
| Modification(s) |
|---|
| Modifier | Organization | Date | Comment |
|---|
| Eugene Lebanidze | Cigital, Inc | 2007-02-26 | Fleshed out content to CAPEC schema from the original descriptions in "Exploiting Software" | | Sean Barnum | Cigital, Inc | 2007-03-05 | Review and revise | | Richard Struse | VOXEM, Inc | 2007-03-26 | Review and feedback leading to changes in Related Attack Patterns | | Sean Barnum | Cigital, Inc | 2007-04-13 | Modified pattern content according to review and feedback |
|
| Attack Pattern ID | Pattern Abstraction: Detailed 58 | | Typical Severity | High | | Description | Summary Rest uses standard HTTP (Get, Put, Delete) style permissions methods, but these are not necessarily correlated generally with back end programs. Strict interpretation of HTTP get methods means that these HTTP Get services should not be used to delete information on the server, but there is no access control mechanism to back up this logic. This means that unless the services are properly ACL'd and the application's service implementation are following these guidelines then an HTTP request can easily execute a delete or update on the server side. The attacker identifies a HTTP Get URL such as http://victimsite/updateOrder, which calls out to a program to update orders on a database or other resource. The URL is not idempotent so the request can be submitted multiple times by the attacker, additionally, the attacker may be able to exploit the URL published as a Get method that actually performs updates (instead of merely retrieving data). This may result in malicious or inadvertant altering of data on the server. | | Attack Prerequisites | The attacker needs to be able to identify HTTP Get URLs. The Get methods must be set to call applications that perform operations other than get such as update and delete. | | Typical Likelihood of Exploit |
High
| | Methods of Attack | | | Examples-Instances | Description The HTTP Get method is designed to retrieve resources and not to alter the state of the application or resources on the server side. However, developers can easily code programs that accept a HTTP Get request that do in fact create, update or delete data on the server. Both Flickr (http://www.flickr.com/services/api/flickr.photosets.delete.html) and del.icio.us (http://del.icio.us/api/posts/delete) have implemented delete operations using standard HTTP Get requests. These HTTP Get methods do delete data on the server side, despite being called from Get which is not supposed to alter state. | | Attacker Skill or Knowledge Required | Low: It is relatively straightforward to identify an HTTP Get method that changes state on the server side and executes against an overprivileged system interface | | Probing Techniques | Attacker may enumerate URLs to identify vulnerable services. | | Solutions and Mitigations | Design: Enforce principle of least privilege Implementation: Ensure that HTTP Get methods only retrieve state and do not alter state on the server side Implementation: Ensure that HTTP methods have proper ACLs based on what the funcitonality they expose | | Attack Motivation-Consequences | - Data Modification
- Privilege Escalation
| | Injection Vector | Payload delivered through standard communication protocols. In the Flickr and del.icio.us examples above, this is done through a normal web browser | | Payload | Command(s) executed directly on host | | Activation Zone | Client machine and client network | | Payload Activation Impact | Enables attacker to execute server side code with any commands that the program owner has privileges to. | | Related Weaknesses | | CWE-ID | Weakness Name | Weakness Relationship Type |
|---|
| 267 | Privilege Defined With Unsafe Actions | Targeted | | 269 | Insecure Privilege Management | Targeted | | 264 | Permissions, Privileges, and Access Controls | Targeted |
| | Related Attack Patterns | | ID | Name | Relationship Type | Relationship Description |
|---|
| 1 | Accessing Functionality Not Properly Constrained by ACLs | More Detailed | |
| | Purpose | Penetration Exploitation | | CIA Impact | | Confidentiality Impact | Integrity Impact | Availability Impact |
|---|
| High | High | Low |
| | Technical Context | | Architectural Paradigm | Framework | Platform | Language |
|---|
| SOA | All | All | All |
| | References | Mark O'Neill, "Security for REST Web Services", http://www.vordel.com/downloads/rsa_conf_2006.pdf | | Source | | Submission(s) |
|---|
| Submitter | Organization | Date | Comment |
|---|
| Gunnar Peterson | | 2007-02-28 | |
| Modification(s) |
|---|
| Modifier | Organization | Date | Comment |
|---|
| Sean Barnum | Cigital, Inc | 2007-03-07 | Review and revise | | Richard Struse | VOXEM, Inc | 2007-03-26 | Review and feedback leading to changes in Description | | Sean Barnum | Cigital, Inc | 2007-04-13 | Modified pattern content according to review and feedback |
|
| Attack Pattern ID | Pattern Abstraction: Detailed 59 | | Typical Severity | High | | Description | Summary This attack targets predictable session ID in order to gain privileges. The attacker can predict the session ID used during a transaction to perform spoofing and session hijacking. Attack Execution Flow Explore Find Session IDs: The attacker interacts with the target host and finds that session IDs are used to authenticate users. | Attack Step
Techniques |
|---|
| Description | Environments |
|---|
| An attacker makes many anonymous connections and records the session IDs assigned. | env-Web env-Peer2Peer env-CommProtocol env-ClientServer | | An attacker makes authorized connections and records the session tokens or credentials issued. | env-Web env-Peer2Peer env-CommProtocol env-ClientServer |
| Indicators of
Susceptibility |
|---|
| ID | Type | Description | Environments |
|---|
| c59s1i1 | Positive | Web applications use session IDs | env-Web | | c59s1i2 | Positive | Network systems issue session IDs or connection IDs | env-CommProtocol env-ClientServer env-Peer2Peer |
| Security
Controls |
|---|
| ID | Type | Description |
|---|
| c59s1s1 | Detective | Monitor logs for unusual amounts of invalid sessions. | | c59s1s2 | Detective | Monitor logs for unusual amounts of invalid connections or invalid requests from unauthorized hosts. |
Characterize IDs: The attacker studies the characteristics of the session ID (size, format, etc.). As a results the attacker finds that legitimate session IDs are predictable. | Attack Step
Techniques |
|---|
| Description | Environments |
|---|
| Cryptanalysis. The attacker uses cryptanalysis to determine if the session IDs contain any cryptographic protections. | env-Web env-ClientServer env-Peer2Peer env-CommProtocol | | Pattern tests. The attacker looks for patterns (odd/even, repetition, multiples, or other arithmetic relationships) between IDs | env-Web env-ClientServer env-Peer2Peer env-CommProtocol | | Comparison against time. The attacker plots or compares the issued IDs to the time they were issued to check for correlation. | env-Web env-ClientServer env-Peer2Peer env-CommProtocol |
| Outcomes |
|---|
| ID | Type | Description |
|---|
| c59s2o1 | Success | Patterns are detectable in session IDs | | c59s2o2 | Failure | Session IDs pass NIST FIPS 140 statistical tests for cryptographic randomness. | | c59s2o3 | Success | Session IDs are repeated. |
Experiment Match issued IDs: The attacker brute forces different values of session ID and manages to predict a valid session ID. | Attack Step
Technique |
|---|
| Description | Environments |
|---|
| The attacker models the session ID algorithm enough to produce a compatible series os IDs, or just one match. | env-Web env-ClientServer env-Peer2Peer env-CommProtocol |
| Outcomes |
|---|
| ID | Type | Description |
|---|
| c59s3o2 | Success | Session identifiers successfully spoofed | | c59s3o3 | Failure | No session IDs can be found or exploited |
Exploit Use matched Session ID: The attacker uses the falsified session ID to access the target system. | Attack Step
Techniques |
|---|
| Description | Environments |
|---|
| The attacker loads the session ID into his web browser and browses to restricted data or functionality. | env-Web | | The attacker loads the session ID into his network communications and impersonates a legitimate user to gain access to data or functionality. | env-CommProtocol env-Peer2Peer env-ClientServer |
| Security
Controls |
|---|
| ID | Type | Description |
|---|
| c59s4s1 | Detective | Monitor the correlation between session IDs and other station designations (MAC address, IP address, VLAN, etc.). Alert on session ID reuse from multiple sources. | | c59s4s2 | Preventative | Terminate both sessions if an ID is used from multiple origins. |
| | Attack Prerequisites | The target host uses session IDs to keep track of the users. Session IDs are used to control access to resources. The session IDs used by the target host are predictable.For example, the session IDs are generated using predictable information (e.g., time). | | Typical Likelihood of Exploit |
High
| | Methods of Attack | - Spoofing
- Brute Force
- Analysis
| | Examples-Instances | Description Jetty before 4.2.27, 5.1 before 5.1.12, 6.0 before 6.0.2, and 6.1 before 6.1.0pre3 generates predictable session identifiers using java.util.random, which makes it easier for remote attackers to guess a session identifier through brute force attacks, bypass authentication requirements, and possibly conduct cross-site request forgery attacks. Related Vulnerability Description mod_usertrack in Apache 1.3.11 through 1.3.20 generates session ID's using predictable information including host IP address, system time and server process ID, which allows local users to obtain session ID's and bypass authentication when these session ID's are used for authentication. Related Vulnerability | | Attacker Skill or Knowledge Required | Low: There are tools to brute force sesion ID. Those tools require a low level of knowledge. Medium/High: Predicting Session ID may require more computation work which uses advanced analysis such as statistic analysis. | | Probing Techniques | The attacker can perform analysis of the randomness of the session generation algortihm. The attacker may need to steal a few valid session IDs using a different type of attack. And then use those session ID to predict the following ones. The attacker can use brute force tools to find a valid session ID. | | Solutions and Mitigations | Use a strong source of randomness to generate a session ID. Use adequate length session IDs Do not use information available to the user in order to generate session ID (e.g., time). Ideas for creating random numbers are offered by Eastlake [RFC1750] Encrypt the session ID if you expose it to the user. For instance session ID can be stored in a cookie in encrypted format. | | Attack Motivation-Consequences | | | Related Weaknesses | | CWE-ID | Weakness Name | Weakness Relationship Type |
|---|
| 290 | Authentication Bypass by Spoofing | Targeted | | 330 | Use of Insufficiently Random Values | Targeted | | 331 | Insufficient Entropy | Targeted | | 346 | Origin Validation Error | Targeted | | 488 | Data Leak Between Sessions | Secondary | | 539 | Information Leak Through Persistent Cookies | Secondary | | 200 | Information Leak (Information Disclosure) | Secondary | | 6 | J2EE Misconfiguration: Insufficient Session-ID Length | Targeted | | 285 | Improper Access Control (Authorization) | Secondary | | 384 | Session Fixation | Secondary | | 693 | Protection Mechanism Failure | Targeted | | 719 | OWASP Top Ten 2007 Category A8 - Insecure Cryptographic Storage | Secondary |
| | Related Security Principles | - Securing the Weakest Link
| | Purpose | Penetration | | CIA Impact | | Confidentiality Impact | Integrity Impact | Availability Impact |
|---|
| High | High | Low |
| | Technical Context | | Architectural Paradigm | Framework | Platform | Language |
|---|
| Client-Server | J2EE | All | All |
| | References | G. Hoglund and G. McGraw. Exploiting Software: How to Break Code. Addison-Wesley, February 2004. | | Source | | Submission(s) |
|---|
| Submitter | Organization | Date | Comment |
|---|
| Eric Dalci | Cigital, Inc | 2007-01-25 | |
| Modification(s) |
|---|
| Modifier | Organization | Date | Comment |
|---|
| Sean Barnum | Cigital, Inc | 2007-03-07 | Review and revise |
|
| Attack Pattern ID | Pattern Abstraction: Detailed 64 | | Typical Severity | High | | Description | Summary This attack targets the encoding of the URL combined with the encoding of the slash characters. An attacker can take advantage of the multiple way of encoding an URL and abuse the interpretation of the URL. An URL may contain special character that need special syntax handling in order to be interpreted. Special characters are represented using a percentage character followed by two digits representing the octet code of the original character (%HEX-CODE). For instance US-ASCII space character would be represented with %20. This is often referred as escaped ending or percent-encoding. Since the server decodes the URL from the requests, it may restrict the access to some URL paths by validating and filtering out the URL requests it received. An attacker will try to craft an URL with a sequence of special characters which once interpreted by the server will be equivalent to a forbidden URL. It can be difficult to protect against this attack since the URL can contain other format of encoding such as UTF-8 encoding, Unicode-encoding, etc. Attack Execution Flow The attacker accesses the server using a specific URL. The attacker tries to encode some special characters in the URL. The attacker find out that some characters are not filtered properly. The attacker crafts a malicious URL string request and sends it to the server. The server decodes and interprets the URL string. Unfortunately since the input filtering is not done properly, the special characters have harmful consequences.
| | Attack Prerequisites | The application accepts and decodes URL string request. The application performs insufficient filtering/canonicalization on the URLs. | | Typical Likelihood of Exploit |
High
| | Methods of Attack | - Injection
- Protocol Manipulation
- API Abuse
| | Examples-Instances | Description Attack Example: Combined Encodings CesarFTP
Alexandre Cesari released a freeware FTP server for Windows that fails to provide proper filtering against multiple encoding. The FTP server, CesarFTP, included a Web server component that could be attacked with a combination of the triple-dot and URL encoding attacks. An attacker could provide a URL that included a string like /...%5C/ This is an interesting exploit because it involves an aggregation of several tricks—the escape character, URL encoding, and the triple dot. Related Vulnerability | | Attacker Skill or Knowledge Required | Low - An attacker can try special characters in the URL and bypass the URL validation. Medium - The attacker may write a script to defeat the input filtering mechanism. | | Probing Techniques | An attacker can manually inject special characters in the URL string request and observe the results of the request. Custom scripts can also be used. For example, a good script for verifying the correct interpretation of UTF-8 encoded characters can be found at http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt Automated tools such as fuzzer can be used to test the URL decoding and filtering. | | Indicators-Warnings of Attack | If the first decoding process has left some invalid or blacklisted characters, that may be a sign that the request is malicious. Traffic filtering with IDS (or proxy) can detect requests with suspicious URLs. IDS may use signature based identification to reveal such URL based attacks. | | Obfuscation Techniques | Sometime the percent escaping can be used to obfuscate the attack itself. Alternative method of data encoding can be used. Obfuscation technique such as IP address encoding can also be used (See reference section : "URL encoded attacks", by Gunter Ollmann). | | Solutions and Mitigations | Assume all input is malicious. Create a white list that defines all valid input to the software system based on the requirements specifications. Input that does not match against the white list should not be permitted to enter into the system. Test your decoding process against malicious input. Be aware of the threat of alternative method of data encoding and obfuscation technique such as IP address encoding. When client input is required from web-based forms, avoid using the "GET" method to submit data, as the method causes the form data to be appended to the URL and is easily manipulated. Instead, use the "POST method whenever possible. Any security checks should occur after the data has been decoded and validated as correct data format. Do not repeat decoding process, if bad character are left after decoding process, treat the data as suspicious, and fail the validation process. Refer to the RFCs to safelly decode URL. Regular expression can be used to match safe URL patterns. However, that may discard valid URL requests if the regular expression is too restrictive. There are tools to scan HTTP requests to the server for valid URL such as URLScan from Microsoft (http://www.microsoft.com/technet/security/tools/urlscan.mspx). | | Attack Motivation-Consequences | - Information Leakage
- Denial of Service
- Run Arbitrary Code
- Information Leakage
- Privilege Escalation
| | Context Description | Most web programming languages have built in API to perform URL Encoding and URL Decoding. For instance PHP uses "urlencode(string)" and "urldecode(string)". Java uses "java.net.URLEncode.encode(String)". | | Related Weaknesses | | CWE-ID | Weakness Name | Weakness Relationship Type |
|---|
| 177 | Failure to Handle URL Encoding (Hex Encoding) | Targeted | | 171 | Cleansing, Canonicalization, and Comparison Errors | Targeted | | 173 | Failure to Handle Alternate Encoding | Targeted | | 172 | Encoding Error | Targeted | | 73 | External Control of File Name or Path | Targeted | | 21 | Pathname Traversal and Equivalence Errors | Targeted | | 74 | Failure to Sanitize Data into a Different Plane (aka 'Injection') | Targeted | | 20 | Improper Input Validation | Targeted | | 697 | Insufficient Comparison | Targeted | | 707 | Failure to Enforce that Messages or Data are Well-Formed | Targeted |
| | Related Attack Patterns | | ID | Name | Relationship Type | Relationship Description |
|---|
| Using Alternate Encodings to Bypass Validation Logic | More Detailed | | | 71 | Using Unicode Encoding to Bypass Validation Logic | Similar | | | 79 | Using Slashes in Alternate Encoding | Similar | | | 72 | URL Encoding | Similar | | | 43 | Exploiting Multiple Input Interpretation Layers | Similar | |
| | Related Security Principles | | | Purpose | Penetration | | CIA Impact | | Confidentiality Impact | Integrity Impact | Availability Impact |
|---|
| Medium | High | Medium |
| | Technical Context | | Architectural Paradigm | Framework | Platform | Language |
|---|
| All | All | All | All |
| | References | G. Hoglund and G. McGraw. Exploiting Software: How to Break Code. Addison-Wesley, February 2004. CWE - Input Validation URL encoded attacks, by Gunter Ollmann - http://www.cgisecurity.com/lib/URLEmbeddedAttacks.html Uniform Resource Identifier (URI): Generic Syntax, RFC 3886 - http://www.ietf.org/rfc/rfc3986.txt URL Uniform Resource Locators (URL) RFC - http://rfc.net/rfc1738.html URL encoding reference - http://www.w3schools.com/tags/ref_urlencode.asp The URLEncode and URLDecode Page - http://www.albionresearch.com/misc/urlencode.php David Wheeler - Validating URIs - http://www.dwheeler.com/secure-programs/Secure-Programs-HOWTO/filter-html.html#VALIDATING-URIS | | Source | | Submission(s) |
|---|
| Submitter | Organization | Date | Comment |
|---|
| G. Hoglund and G. McGraw. Exploiting Software: How to Break Code. Addison-Wesley, February 2004. | Cigital, Inc | 2007-03-01 | |
| Modification(s) |
|---|
| Modifier | Organization | Date | Comment |
|---|
| Eric Dalci | Cigital, Inc | 2007-02-13 | Fleshed out content to CAPEC schema from the original descriptions in "Exploiting Software" | | Sean Barnum | Cigital, Inc | 2007-03-05 | Review and revise | | Richard Struse | VOXEM, Inc | 2007-03-26 | Review and feedback leading to changes in Name | | Sean Barnum | Cigital, Inc | 2007-04-13 | Modified pattern content according to review and feedback |
|
| Attack Pattern ID | Pattern Abstraction: Detailed 67 | | Typical Severity | Very High | | Description | Summary This attack targets the format string vulnerabilities in the syslog() function. An attacker would typically inject malicious input in the format string parameter of the syslog function. This is a common problem, and many public vulnerabilities and associated exploits have been posted. Attack Execution Flow The attacker finds that he can inject data to the format string parameter of Syslog(). The attacker craft a malicious input and inject it into the format string parameter. From now on, the attacker can exeute arbitrary code and do more damage.
| | Attack Prerequisites | The format string argument of the Syslog function can be tainted with user supplid data. | | Typical Likelihood of Exploit |
High
| | Methods of Attack | | | Examples-Instances | Description Format string vulnerability in TraceEvent function for ntop before 2.1 allows remote attackers to execute arbitrary code by causing format strings to be injected into calls to the syslog function, via (1) an HTTP GET request, (2) a user name in HTTP authentication, or (3) a password in HTTP authentication. Related Vulnerability | | Probing Techniques | If the source code of the application is available, an attacker can use static analysis tools to spot a syslog vulnerability (a simple grep may also work). If the source code is not available, automated tools such as Fuzzer and advanced Web Scanner can be used. If the tool supplied data reaches the syslog's format string argument, the application under scrutiny may have unexpected behavior. If the source code is not available, a more complexe technique involve the use of library and system call tracer combined with the use of binary auditing tool such as IDA Pro. Reverse Engineering technique can be used to find format string vulnerability in the syslog function call. For instance it is possible to get the address of the buffer that is later used as the format string when reading data | | Solutions and Mitigations | The code should be reviewed for misuse of the Syslog function call. Manual or automated code review can be used. The reviewer needs to ensure that all format string functions are passed a static string which cannot be controlled by the user and that the proper number of arguments are always sent to that function as well. If at all possible, do not use the %n operator in format strings. The following code shows a correct usage of Syslog(): ... syslog(LOG_ERR, "%s", cmdBuf); ... The following code shows a vulnerable usage of Syslog(): ... syslog(LOG_ERR, cmdBuf); // the buffer cmdBuff is taking user supplied data. ... | | Attack Motivation-Consequences | - Run Arbitrary Code
- Denial of Service
- Privilege Escalation
- Data Modification
| | Context Description | Format String Vulnerabilities When you get right down to it, format strings vulnerabilities are relatively simple in nature. An API call that takes a format string (i.e., %s) can be exploited when the format string argument is controlled by a remote attacker. Unfortunately, the problem exists mainly because of laziness on the part of the programmer. However, the problem is so simple that it can be detected automatically using simple code scanners. Thus, once the format string vulnerability was publicized in the late 1990s, it was rapidly hunted down and eliminated in most software. Here is a trivial function that suffers from a format string problem: void some_func(char *c) { printf(c); } | | Injection Vector | Untrusted user supplied data is the injection vector. | | Payload | The maliciously crafted data can read from the stack if passed to the Syslog function as a format String. | | Activation Zone | The signature of the syslog function is as following : "void syslog(int priority, const char *format, ...);"
A vulnerable usage would be : "syslog(LOG_ERR, cmdBuf);" where cmdBuf is a user controlled data which leads to a format string vulnerability. The activation zone is the format String argument which accepts user supplied data. | | Payload Activation Impact | The impacts of this attack can be execution of arbitrary code. Execution of arbitary code can lead to many problems such as corruption of data, unauthorized access, etc. | | Related Weaknesses | | CWE-ID | Weakness Name | Weakness Relationship Type |
|---|
| 120 | Buffer Copy without Checking Size of Input ('Classic Buffer Overflow') | Secondary | | 134 | Uncontrolled Format String | Targeted | | 74 | Failure to Sanitize Data into a Different Plane (aka 'Injection') | Secondary | | 20 | Improper Input Validation | Secondary | | 680 | Integer Overflow to Buffer Overflow | Targeted | | 697 | Insufficient Comparison | Targeted |
| | Related Vulnerabilities | | Vulnerability-ID | Vulnerability Description |
|---|
| CVE-2002-0573 | format string in bad call to syslog function | | CVE-2001-0717 | format string in bad call to syslog function | | CVE-2002-0412 | format string in bad call to syslog function |
| | Related Attack Patterns | | ID | Name | Relationship Type | Relationship Description |
|---|
| Buffer Overflow via Format Strings | More Detailed | |
| | Relevant Security Requirements | Choose a language which is not subject to this flaw. Do not use the Syslog() in your implementation. Use manual or automated code review to spot potential format string vulnerability in functions such as Syslog(), Vsyslog(), snprintf(), etc. | | Related Security Principles | | | Related Guidelines | - Verify that input is of a limited size.
- If the message is coming from an outside source, check for %s type parameters and ensure that bounds will not be overwritten.
- Don't use text from an outside source as a format string.
| | Purpose | Penetration Exploitation | | CIA Impact | | Confidentiality Impact | Integrity Impact | Availability Impact |
|---|
| High | High | High |
| | Technical Context | | Architectural Paradigm | Framework | Platform | Language |
|---|
| All | All | All | All |
| | References | G. Hoglund and G. McGraw. Exploiting Software: How to Break Code. Addison-Wesley, February 2004. CWE - Buffer Errors Exploiting Format String Vulnerabilities, scut / team teso, http://doc.bughunter.net/format-string/exploit-fs.html Halvar Flake, "Auditing binaries for security vulnerabilities", http://www.blackhat.com/presentations/bh-europe-00/HalvarFlake/HalvarFlake.ppt Fortify Taxonomy of Vulnerabilities : http://vulncat.fortifysoftware.com/1/FS.html - Fortify Software (www.fortifysoftware.com) Syslog man page : http://www.rt.com/man/syslog.3.html | | Source | | Submission(s) |
|---|
| Submitter | Organization | Date | Comment |
|---|
| G. Hoglund and G. McGraw. Exploiting Software: How to Break Code. Addison-Wesley, February 2004. | Cigital, Inc | 2007-03-01 | |
| Modification(s) |
|---|
| Modifier | Organization | Date | Comment |
|---|
| Eric Dalci | Cigital, Inc | 2007-02-13 | Fleshed out content to CAPEC schema from the original descriptions in "Exploiting Software" | | Sean Barnum | Cigital, Inc | 2007-03-05 | Review and revise | | Richard Struse | VOXEM, Inc | 2007-03-26 | Review and feedback leading to changes in Related Attack Patterns | | Sean Barnum | Cigital, Inc | 2007-04-13 | Modified pattern content according to review and feedback |
|
| Attack Pattern ID | Pattern Abstraction: Detailed 70 | | Typical Severity | High | | Description | Summary An attacker may try certain common (default) usernames and passwords to gain access into the system and perform unauthorized actions. An attacker may try an intelligent brute force using known vendor default credentials as well as a dictionary of common usernames and passwords. Many vendor products come preconfigured with default (and thus well known) usernames and passwords that should be deleted prior to usage in a production environment. It is a common mistake to forget to remove these default login credentials. Another problem is that users would pick very simple (common) passwords (e.g. "secret" or "password") that make it easier for the attacker to gain access to the system compared to using a brute force attack or even a dictionary attack using a full dictionary. | | Attack Prerequisites | The system uses one factor password based authentication. | | Typical Likelihood of Exploit |
Medium
| | Methods of Attack | | | Examples-Instances | Description User Bob sets his password to "123". If the system does not have password strength enforcement against a sound password policy, this password may be admitted. A simple numeric sequence like this is one of the most common passwords and is easily guessable by an attacker. Description Cisco 2700 Series Wireless Location Appliances (version 2.1.34.0 and earlier) have a default administrator username "root" with a password "password". This allows remote attackers to easily obtain administrative privileges. Related Vulnerability | | Attacker Skill or Knowledge Required | Low: An attacker just needs to gain access to common default usernames/passwords specific to the technologies used by the system. Additionally, a brute force attack leveraging common passwords can be easily realized if the user name is known. | | Resources Required | Technology or vendor specific list of default usernames and passwords. | | Probing Techniques | Try to determine what products are used in the implementation of the system. Determine if there are any default accounts associated with those products. | | Indicators-Warnings of Attack | Many incorrect login attempts are detected by the system. | | Obfuscation Techniques | Try to spoof IP addresses so that it does not look like the incorrect log in attempts are coming from the same computer. | | Solutions and Mitigations | Delete all default account credentials that may be put in by the product vendor. Implement a password throttling mechanism. This mechanism should take into account both the IP address and the log in name of the user. Put together a strong password policy and make sure that all user created passwords comply with it. Alternatively automatically generate strong passwords for users. Passwords need to be recycled to prevent aging, that is every once in a while a new password must be chosen. | | Attack Motivation-Consequences | | | Related Weaknesses | | CWE-ID | Weakness Name | Weakness Relationship Type |
|---|
| 521 | Weak Password Requirements | Targeted | | 262 | Not Using Password Aging | Targeted | | 263 | Password Aging with Long Expiration | Targeted | | 693 | Protection Mechanism Failure | Targeted |
| | Related Attack Patterns | | ID | Name | Relationship Type | Relationship Description |
|---|
| 16 | Dictionary-based Password Attack | More Abstract | | | 49 | Password Brute Forcing | Occasionally Follows | | | 55 | Rainbow Table Password Cracking | Occasionally Follows | |
| | Related Security Principles | | | Purpose | Penetration | | CIA Impact | | Confidentiality Impact | Integrity Impact | Availability Impact |
|---|
| High | High | Medium |
| | Technical Context | | Architectural Paradigm | Framework | Platform | Language |
|---|
| All | All | All | All |
| | Source | | Submission(s) |
|---|
| Submitter | Organization | Date | Comment |
|---|
| Eugene Lebanidze | Cigital, Inc | 2007-02-26 | |
| Modification(s) |
|---|
| Modifier | Organization | Date | Comment |
|---|
| Sean Barnum | Cigital, Inc | 2007-03-01 | Review and revision of content |
|
| Attack Pattern ID | Pattern Abstraction: Detailed 78 | | Typical Severity | High | | Description | Summary This attack targets the use of the backslash in alternate encoding. An attacker can provide a backslash as a leading character and causes a parser to believe that the next character is special. This is called an escape. By using that trick, the attacker tries to exploit alternate ways to encode the same character which leads to filter problems and opens avenues to attack. Attack Execution Flow The attacker can send input data to the host target (e.g., via http request or command line request The attacker craft malicious input data which includes escaped slashes. The attacker may need multiple attempts before finding a successful combination.
| | Attack Prerequisites | The application accepts the backlash character as escape character. The application server does incomplete input data decoding, filtering and validation. | | Typical Likelihood of Exploit |
High
| | Methods of Attack | - Injection
- Protocol Manipulation
- API Abuse
| | Examples-Instances | Description For example, the byte pair \0 might result in a single zero byte (a NULL) being sent. Another example is \t, which is sometimes converted into a tab character. There is often an equivalent encoding between the back slash and the escaped back slash. This means that \/ results in a single forward slash. A single forward slash also results in a single forward slash. The encoding looks like this:
/ yields / \/ yields / Description Attack Example: Escaped Slashes in Alternate Encodings
An attack leveraging this pattern is very simple. If you believe the target may be filtering the slash, attempt to supply \/ and see what happens. Example command strings to try out include CWD ..\/..\/..\/..\/winnt which converts in many cases to CWD ../../../../winnt To probe for this kind of problem, a small C program that uses string output routines can be very useful. File system calls make excellent testing fodder. The simple snippet int main(int argc, char* argv[]) { puts("\/ \\ \? \. \| "); return 0; } produces the output / \ ? . | Clearly, the back slash is ignored, and thus we have hit on a number of alternative encodings to experiment with. Given our previous example, we can extend the attack to include other possibilities: CWD ..\?\?\?\?\/..\/..\/..\/winnt CWD \.\.\/\.\.\/\.\.\/\.\.\/winnt CWD ..\|\|\|\|\/..\/..\/..\/winnt | | Attacker Skill or Knowledge Required | Low - The attacker can naively try backslash character and discover that the target host uses it as escape character. Medium - The attacker may need deep understanding of the host target in order to exploit the vulnerability. The attacker may also use automated tools to probe for this vulnerability. | | Probing Techniques | An attacker can manually inject backslash characters in the data sent to the target host and observe the results of the request. The attacker may also run scripts or automated tools against the target host to uncover a vulnerability related to the use of the backslash character. | | Indicators-Warnings of Attack | A attacker can use a fuzzer in order to probe for this vulnerability. The fuzzer should generate suspicious network activity noticeable by an intrusion detection system. | | Obfuscation Techniques | Alternative method of data encoding can be used. | | Solutions and Mitigations | Verify that the user-supplied data does not use backslash character to escape malicious characters. Assume all input is malicious. Create a white list that defines all valid input to the software system based on the requirements specifications. Input that does not match against the white list should not be permitted to enter into the system. Be aware of the threat of alternative method of data encoding. Regular expressions can be used to filter out backslash. Make sure you decode before filtering and validating the untrusted input data. In the case of path traversals, use the principle of least privilege when determining access rights to file systems. Do not allow users to access directories/files that they should not access. Any security checks should occur after the data has been decoded and validated as correct data format. Do not repeat decoding process, if bad character are left after decoding process, treat the data as suspicious, and fail the validation process. Avoid making decisions based on names of resources (e.g. files) if those resources can have alternate names. | | Attack Motivation-Consequences | - Information Leakage
- Denial of Service
- Run Arbitrary Code
- Information Leakage
- Privilege Escalation
| | Injection Vector | The user supplied data (e.g., HTTP request) | | Payload | The backslash character injected in the user supplied data. The backslash character can be obfuscated with alternate encoding. | | Activation Zone | The command or request interpreter used on the host target may consider the backslash character as escape character. | | Payload Activation Impact | The character following the backslash character will be escaped (i.e, unfiltered) and may cause harmful effects. | | Related Weaknesses | | CWE-ID | Weakness Name | Weakness Relationship Type |
|---|
| 180 | Incorrect Behavior Order: Validate Before Canonicalize | Targeted | | 181 | Incorrect Behavior Order: Validate Before Filter | Targeted | | 173 | Failure to Handle Alternate Encoding | Targeted | | 171 | Cleansing, Canonicalization, and Comparison Errors | Targeted | | 172 | Encoding Error | Targeted | | 73 | External Control of File Name or Path | Targeted | | 21 | Pathname Traversal and Equivalence Errors | Targeted | | 74 | Failure to Sanitize Data into a Different Plane (aka 'Injection') | Targeted | | 20 | Improper Input Validation | Targeted | | 697 | Insufficient Comparison | Targeted | | 707 | Failure to Enforce that Messages or Data are Well-Formed | Targeted |
| | Related Attack Patterns | | ID | Name | Relationship Type | Relationship Description |
|---|
| 64 | Using Slashes and URL Encoding Combined to Bypass Validation Logic | Similar | | | 79 | Using Slashes in Alternate Encoding | More Detailed | | | 71 | Using Unicode Encoding to Bypass Validation Logic | Similar | | | 43 | Exploiting Multiple Input Interpretation Layers | Similar | | | Relative Path Traversal | More Detailed | | | Using Alternate Encodings to Bypass Validation Logic | More Detailed | |
| | Relevant Security Requirements | All client-supplied input must be validated through filtering and all output must be properly escaped. | | Related Security Principles | | | Related Guidelines | - Never trust user-supplied input.
| | Purpose | Penetration Exploitation | | CIA Impact | | Confidentiality Impact | Integrity Impact | Availability Impact |
|---|
| High | High | Medium |
| | Technical Context | | Architectural Paradigm | Framework | Platform | Language |
|---|
| All | All | All | All |
| | References | G. Hoglund and G. McGraw. Exploiting Software: How to Break Code. Addison-Wesley, February 2004. CWE - Input Validation | | Source | | Submission(s) |
|---|
| Submitter | Organization | Date | Comment |
|---|
| G. Hoglund and G. McGraw. Exploiting Software: How to Break Code. Addison-Wesley, February 2004. | Cigital, Inc | 2007-03-01 | |
| Modification(s) |
|---|
| Modifier | Organization | Date | Comment |
|---|
| Eric Dalci | Cigital, Inc | 2007-02-13 | Fleshed out content to CAPEC schema from the original descriptions in "Exploiting Software" | | Sean Barnum | Cigital, Inc | 2007-03-07 | Review and revise | | Richard Struse | VOXEM, Inc | 2007-03-26 | Review and feedback leading to changes in Related Attack Patterns | | Sean Barnum | Cigital, Inc | 2007-04-16 | Modified pattern content according to review and feedback |
|
| Attack Pattern ID | Pattern Abstraction: Detailed 79 | | Typical Severity | High | | Description | Summary This attack targets the encoding of the Slash characters. An attacker would try to exploit common filtering problems related to the use of the slashes characters to gain access to resources on the target host. Directory-driven systems, such as file systems and databases, typically use the slash character to indicate traversal between directories or other container components. For murky historical reasons, PCs (and, as a result, Microsoft OSs) choose to use a backslash, whereas the UNIX world typically makes use of the forward slash. The schizophrenic result is that many MS-based systems are required to understand both forms of the slash. This gives the attacker many opportunities to discover and abuse a number of common filtering problems. The goal of this pattern is to discover server software that only applies filters to one version, but not the other. Attack Execution Flow The attacker has access to a resource path and required to use slashes as resource delimiter. The attacker tries variation and combination of the slashes characters in different encoding format. The attacker found an unfiltered combination which maps to a valid path and accesses unauthorized resources (directories, files, etc.)
| | Attack Prerequisites | The application server accepts paths to locate resources. The application server does insufficient input data validation on the resource path requested by the user. The access right to resources are not set properly. | | Typical Likelihood of Exploit |
High
| | Methods of Attack | - Injection
- Protocol Manipulation
- API Abuse
| | Examples-Instances | Description Attack Example: Slashes in Alternate Encodings
The two following requests are equivalent on most Web servers: http://target server/some_directory\..\..\..\winnt is equivalent to http://target server/some_directory/../../../winnt Multiple encoding conversion problems can also be leveraged as various slashes are instantiated in URL-encoded, UTF-8, or unicode. Consider the strings http://target server/some_directory\..%5C..%5C..\winnt where %5C is equivalent to the \ character. | | Attacker Skill or Knowledge Required | Low: An attacker can try variation of the slashes characters.
Medium: An attacker can use more sophisticated tool or script to scan a website and find a path filtering problem. | | Probing Techniques | An attacker can try different encoding formats for the slashes characters and see if they produce the same filtering results. Automated tools such as fuzzer can be used to test the URL decoding and filtering. Custom scripts can also be used. For example, a good script for verifying the correct interpretation of UTF-8 encoded characters can be found at http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt | | Indicators-Warnings of Attack | If the first path decoding process has left some invalid or blacklisted characters, that may be a sign that the request is malicious. Traffic filtering with IDS (or proxy) can detect request with suspicious URLs. IDS may use signature based identification to reveal such URL based attacks. A attacker can use a fuzzer in order to probe for a UTF-8 encoding vulnerability. The fuzzer should generate suspiscious network activity. | | Obfuscation Techniques | Typically the obfuscation here is the use of different alternate encoding format (UTF-8, Unicode, etc,) | | Solutions and Mitigations | Any security checks should occur after the data has been decoded and validated as correct data format. Do not repeat decoding process, if bad character are left after decoding process, treat the data as suspicious, and fail the validation process. Refer to the RFCs to safelly decode URL. When client input is required from web-based forms, avoid using the "GET" method to submit data, as the method causes the form data to be appended to the URL and is easily manipulated. Instead, use the "POST method whenever possible. There are tools to scan HTTP requests to the server for valid URL such as URLScan from Microsoft (http://www.microsoft.com/technet/security/tools/urlscan.mspx) Be aware of the threat of alternative method of data encoding and obfuscation technique such as IP address endoding. (See related guideline section) Test your path decoding process against malicious input. In the case of path traversals, use the principle of least privilege when determining access rights to file systems. Do not allow users to access directories/files that they should not access. Assume all input is malicious. Create a white list that defines all valid input to the application based on the requirements specifications. Input that does not match against the white list should not be permitted to enter into the system. | | Attack Motivation-Consequences | - Information Leakage
- Run Arbitrary Code
- Privilege Escalation
| | Injection Vector | The injection vector is a string path such as URL path. | | Payload | The injection vector is a string path with malicious slashes characters. Alternate encoding format can also be used to code the slashes characters. | | Payload Activation Impact | The impact of the payload is access to unauthorized resources. | | Related Weaknesses | | CWE-ID | Weakness Name | Weakness Relationship Type |
|---|
| 173 | Failure to Handle Alternate Encoding | Targeted | | 171 | Cleansing, Canonicalization, and Comparison Errors | Targeted | | 180 | Incorrect Behavior Order: Validate Before Canonicalize | Targeted | | 181 | Incorrect Behavior Order: Validate Before Filter | Targeted | | 20 | Improper Input Validation | Targeted | | 74 | Failure to Sanitize Data into a Different Plane (aka 'Injection') | Targeted | | 73 | External Control of File Name or Path | Targeted | | 21 | Pathname Traversal and Equivalence Errors | Targeted | | 185 | Incorrect Regular Expression | Secondary | | 200 | Information Leak (Information Disclosure) | Secondary | | 697 | Insufficient Comparison | Targeted | | 707 | Failure to Enforce that Messages or Data are Well-Formed | Targeted |
| | Related Attack Patterns | | ID | Name | Relationship Type | Relationship Description |
|---|
| 64 | Using Slashes and URL Encoding Combined to Bypass Validation Logic | More Abstract | | | 78 | Using Escaped Slashes in Alternate Encoding | More Abstract | | | 71 | Using Unicode Encoding to Bypass Validation Logic | Similar | | | 43 | Exploiting Multiple Input Interpretation Layers | Similar | | | Relative Path Traversal | More Detailed | | | Using Alternate Encodings to Bypass Validation Logic | More Detailed | |
| | Related Security Principles | - Least privilege
- Reluctance to trust
| | Purpose | Penetration Exploitation | | CIA Impact | | Confidentiality Impact | Integrity Impact | Availability Impact |
|---|
| High | High | Medium |
| | Technical Context | | Architectural Paradigm | Framework | Platform | Language |
|---|
| All | All | All | All |
| | References | G. Hoglund and G. McGraw. Exploiting Software: How to Break Code. Addison-Wesley, February 2004. UTF-8 and Unicode FAQ for Unix/Linux, by Markus Kuhn - http://www.cl.cam.ac.uk/~mgk25/unicode.html URL encoded attacks, by Gunter Ollmann - http://www.cgisecurity.com/lib/URLEmbeddedAttacks.html | | Source | | Submission(s) |
|---|
| Submitter | Organization | Date | Comment |
|---|
| G. Hoglund and G. McGraw. Exploiting Software: How to Break Code. Addison-Wesley, February 2004. | Cigital, Inc | 2007-03-01 | |
| Modification(s) |
|---|
| Modifier | Organization | Date | Comment |
|---|
| Eric Dalci | Cigital, Inc | 2007-02-13 | Fleshed out content to CAPEC schema from the original descriptions in "Exploiting Software" | | Sean Barnum | Cigital, Inc | 2007-03-07 | Review and revise | | Richard Struse | VOXEM, Inc | 2007-03-26 | Review and feedback leading to changes in Related Attack Patterns | | Sean Barnum | Cigital, Inc | 2007-04-16 | Modified pattern content according to review and feedback |
|
| Attack Pattern ID | Pattern Abstraction: Detailed 57 | | Typical Severity | Very High | | Description | Summary This attack utlizes a Rest(REpresentational State Transfer)-style applications' trust in the system resources and environment to place man in the middle once SSL is terminated. Rest applications premise is that they leverage existing infrastructure to deliver web services functionality. An example of this is a Rest application that uses HTTP Get methods and receives a HTTP response with a XML document. These Rest style web services are deployed on existing infrastructure such as Apache and IIS web servers with no SOAP stack required. Unfortunately from a security standpoint, there frequently is no interoperable identity security mechanism deployed, so Rest developers often fall back to SSL to deliver security. In large data centers, SSL is typically terminated at the edge of the network - at the firewall, load balancer, or router. Once the SSL is terminated the HTTP request is in the clear (unless developers have hashed or encrypted the values, but this is rare). The attacker can utilize a sniffer such as Wireshark to snapshot the credentials, such as username and password that are passed in the clear once SSL is terminated. Once the attacker gathers these credentials, they can submit requests to the web service provider just as authorized user do. There is not typically an authentication on the client side, beyond what is passed in the request itself so once this is compromised, then this is generally sufficient to compromise the service's authentication scheme. | | Attack Prerequisites | Opportuntity to intercept must exist beyond the poing where SSL is terminated. The attacker must be able to insert a listener actively (proxying the communication) or passively (sniffing the communication) in the client-server communication path. | | Typical Likelihood of Exploit |
Medium
| | Methods of Attack | - Protocol Manipulation
- Injection
| | Examples-Instances | Description The Rest service provider uses SSL to protect the communications between the service requester (client) to the service provider. In the instance where SSL is terminated before the communications reach the web server, it is very common in enterprise data centers to terminate SSL at a router, firewall, load balancer, proxy or other device, then the attacker can insert a sniffer into the communication stream and gather all the authentication tokens (such as session credentials, username/passwords combinations, and so on). The Rest service requester and service provider do not have any way to detect this attack. | | Attacker Skill or Knowledge Required | Low: to insert a network sniffer or other listener into the communication stream | | Probing Techniques | Attacker may use a network sniffer to identify authentication credentials once SSL is terminated. | | Solutions and Mitigations | Implementation: Implement message level security such as HMAC in the HTTP communication Design: Utilize defense in depth, do not rely on a single security mechanism like SSL Design: Enforce principle of least privilege | | Attack Motivation-Consequences | | | Injection Vector | HTTP protocol communications | | Payload | Command(s) executed directly on host | | Activation Zone | Client machine and client network | | Payload Activation Impact | Enables attacker to execute server side code with any commands that the program owner has privileges to. | | Related Weaknesses | | CWE-ID | Weakness Name | Weakness Relationship Type |
|---|
| 300 | Channel Accessible by Non-Endpoint (aka 'Man-in-the-Middle') | Targeted | | 287 | Improper Authentication | Targeted | | 724 | OWASP Top Ten 2004 Category A3 - Broken Authentication and Session Management | Targeted | | 693 | Protection Mechanism Failure | Targeted |
| | Purpose | Penetration Exploitation | | CIA Impact | | Confidentiality Impact | Integrity Impact | Availability Impact |
|---|
| High | High | High |
| | Technical Context | | Architectural Paradigm | Framework | Platform | Language |
|---|
| SOA | All | All | All |
| | Source | | Submission(s) |
|---|
| Submitter | Organization | Date | Comment |
|---|
| Gunnar Peterson | | 2007-02-28 | |
| Modification(s) |
|---|
| Modifier | Organization | Date | Comment |
|---|
| Sean Barnum | Cigital, Inc | 2007-03-07 | Review and revise | | Richard Struse | VOXEM, Inc | 2007-03-26 | Review and feedback leading to changes in Description and Attack Prerequisites | | Sean Barnum | Cigital, Inc | 2007-04-13 | Modified pattern content according to review and feedback |
|
| Attack Pattern ID | Pattern Abstraction: Detailed 95 | | Typical Severity | High | | Description | Summary This attack targets the WSDL interface made available by a web service. The attacker may scan the WSDL interface to reveal sensitive information about invocation patterns, underlying technology implementations and associated vulnerabilities. This type of probing is carried out to perform more serious attacks (e.g. parameter tampering, malicious content injection, command injection, etc.). WSDL files provide detailed information about the services ports and bindings available to consumers. For instance, the attacker can submit special characters or malicious content to the Web service and can cause a denial of service condition or illegal access to database records. In addition, the attacker may try to guess other private methods by using the information provided in the WSDL files. Attack Execution Flow The first step is exploratory meaning the attacker scans for WSDL documents. The WDSL document written in XML is like a handbook on how to communicate with the web services provided by the target host. It provides an open view of the application (function details, purpose, functional break down, entry points, message types, etc.). This is very useful information for the attacker. The second step that a attacker would undertake is to analyse the WSDL files and try to find potential weaknesses by sending messages matching the pattern described in the WSDL file. The attacker could run through all of the operations with different message request patterns until a breach is identified. Once an attacker finds a potential weakness, they can craft malicious content to be sent to the system. For instance the attacker may try to submit special characters and observe how the system reacts to an invalid request. The message sent by the attacker may not be XML validated and cause unexpected behavior.
| | Attack Prerequisites | A client program connecting to a web service can read the WSDL to determine what functions are available on the server. The target host exposes vulnerable functions within its WSDL interface. | | Typical Likelihood of Exploit |
High
| | Methods of Attack | | | Examples-Instances | Description A WSDL interface may expose a function vulnerable to SQL Injection. Description The Web Services Description Language (WSDL) allows a web service to advertise its capabilities by describing operations and parameters needed to access the service. As discussed in step 5 of this series, WSDL is often generated automatically, using utilities such as Java2WSDL, which takes a class or interface and builds a WSDL file in which interface methods are exposed as web services.
Because WSDL generation often is automated, enterprising hackers can use WSDL to gain insight into the both public and private services. For example, an organization converting legacy application functionality to a web services framework may inadvertently pass interfaces not intended for public consumption to a WSDL generation tool. The result will be SOAP interfaces that give access to private methods. Another, more subtle WSDL attack occurs when an enterprising attacker uses naming conventions to guess the names of unpublished methods that may be available on the server. For example, a service that offers a stock quote and trading service may publish query methods such as requestStockQuote in its WSDL. However, similar unpublished methods may be available on the server but not listed in the WSDL, such as executeStockQuote. A persistent hacker with time and a library of words and phrases can cycle thru common naming conventions (get, set, update, modify, and so on) to discover unpublished application programming interfaces that open doors into private data and functionality. Source : "Seven Steps to XML Mastery, Step 7: Ensure XML Security", Frank Coyle. See reference section. | | Attacker Skill or Knowledge Required | Low: This attack can be as simple as reading WSDL and starting sending invalid request. Medium: This attack can be used to perform more sophisticated attacks (SQL injection, etc.) | | Probing Techniques | An attacker can request the WSDL file from the target host by sending a SOAP message. There are free Vulnerability testing tool, such as WSDigger to perform WSDL scanning - Foundstone's free Web services security tool performs WSDL scanning, SQL injection and XSS attacks on Web Services. | | Solutions and Mitigations | It is important to protect WSDL file or provide limited access to it. Review the functions exposed by the WSDL interface (specially if you have used a tool to generate it). Make sure that none of them is vulnerable to injection. Ensure the WSDL does not expose functions and APIs that were not intended to be exposed. Pay attention to the function naming convention (within the WSDL interface). Easy to guess function name may be an entry point for attack. Validate the received messages against the WSDL Schema. Incomplete solution. | | Attack Motivation-Consequences | | | Related Weaknesses | | CWE-ID | Weakness Name | Weakness Relationship Type |
|---|
| 538 | File and Directory Information Leaks | Targeted |
| | Related Security Principles | - Defense in Depth
- Never Assuming that Your Secrets Are Safe
- Securing the Weakest Link
| | Purpose | Reconnaissance | | CIA Impact | | Confidentiality Impact | Integrity Impact | Availability Impact |
|---|
| Medium | Medium | High |
| | Technical Context | | Architectural Paradigm | Framework | Platform | Language |
|---|
| SOA | All | All | All |
| | References | CWE - Input Validation "Anatomy of a Web Services Attack", ForumSystems - http://forumsystems.com/papers/Anatomy_of_Attack_wp.pdf "Seven Steps to XML Mastery, Step 7: Ensure XML Security", Frank Coyle - http://www.awprofessional.com/articles/article.asp?p=601349&seqNum=5&rl=1 | | Source | | Submission(s) |
|---|
| Submitter | Organization | Date | Comment |
|---|
| Sean Barnum | Cigital, Inc. | 2007-03-25 | Identified priority for pattern creation |
| Modification(s) |
|---|
| Modifier | Organization | Date | Comment |
|---|
| Eric Dalci | Cigital, Inc. | 2007-03-25 | Fleshed out content for pattern | | Sean Barnum | Cigital, Inc | 2007-04-16 | Review and revise |
|
| Attack Pattern ID | Pattern Abstraction: Detailed 83 | | Typical Severity | High | | Description | Summary An attacker can craft special user-controllable input consisting of XPath expressions to inject the XML database and bypass authentication or glean information that he normally would not be able to. XPath Injection enables an attacker to talk directly to the XML database, thus bypassing the application completely. XPath Injection results form the failure of an application to properly sanitize input used as part of dynamic XPath expressions used to query an XML database. In order to successfully inject XML and retrieve information from a database, an attacker: Attack Execution Flow Determines the user-controllable input that is used without proper validation as part of XPath queries Determines the structure of queries that accept such input Crafts malicious content containing XPath expressions that is not validated by the application and is executed as part of the XPath queries.
| | Attack Prerequisites | XPath queries used to retrieve information stored in XML documents User-controllable input not properly sanitized before being used as part of XPath queries | | Typical Likelihood of Exploit |
High
| | Methods of Attack | | | Examples-Instances | Description Consider an application that uses an XML database to authenticate its users. The application retrieves the user name and password from a request and forms an XPath expression to query the database. An attacker can successfully bypass authentication and login without valid credentials through XPath Injection. This can be achieved by injecting the query to the XML database with XPath syntax that causes the authentication check to fail. Improper validation of user-controllable input and use of a non-parameterized XPath expression enable the attacker to inject an XPath expression that causes authentication bypass. | | Attacker Skill or Knowledge Required | Low - XPath Injection shares the same basic premises with SQL Injection. An attacker must have knowledge of XPath synax and constructs in order to successfully leverage XPath Injection | | Resources Required | None | | Probing Techniques | The attacker tries to inject characters that can cause an XPath error, such as single-quote ('), or content that may cause a malformed XPath expression. If the injection of such content into the input causes an XPath error and the resulting error is displayed unfiltered, the attacker can begin to determine the nature of input validation and structure of XPath expressions used in queries. | | Indicators-Warnings of Attack | Too many exceptions generated by the appplication as a result of malformed XPath queries | | Solutions and Mitigations | Strong input validation - All user-controllable input must be validated and filtered for illegal characters as well as content that can be interpreted in the context of an XPath expression. Characters such as a single-quote(') or operators such as or (|), and (&) and such should be filtered if the application does not expect them in the context in which they appear. If such content cannot be filtered, it must at least be properly escaped to avoid them being interpreted as part of XPath expressions. Use of parameterized XPath queries - Parameterization causes the input to be restricted to certain domains, such as strings or integers, and any input outside such domains is considered invalid and the query fails. Use of custom error pages - Attackers can glean information about the nature of queries from descriptive error messages. Input validation must be coupled with customized error pages that inform about an error without disclosing information about the database or application. | | Attack Motivation-Consequences | - Privilege Escalation
- Information Leakage
| | Context Description | The primary cause of XPath Injection is use of improperly validated input. In the absence of such validation, it becomes possible to inject content that can be interpreted as part of XPath expressions used in querying the XML database. The second most important reason is use of XPath expressions created dynamically to query the database. Another factor, albeit a minor one, is the use of default error pages that reveal information about the structure of XPath queries. It is important to realize that, wherever possible, it is easier to leverage XPath injection than SQL Injection since an XML document usually has no access control associated with it. The attacker can extract the document structure since the contents of the XML document are not bound by privilege considerations in the same manner that tables in a relational database are. Also, in case of SQL injection, the application is limited in querying the database by the privilege of the database account used by the application. Consider the following simple XML document that stores authentication information and a snippet of Java code that uses XPath query to retireve authentication information: <?xml version="1.0"?> <users> <user> <login>john</login> <password>abracadabra</password> <home_dir>/home/john</home_dir> </user> <user> <login>cbc</login> <password>1mgr8</password> <home_dir>/home/cbc</home_dir> </user> </users> The Java code used to retrieve the home directory based on the provided credentials is: XPath xpath = XPathFactory.newInstance().newXPath(); XPathExpression xlogin = xpath.compile("//users/user[login/text()='" + login.getUserName() + "' and password/text() = '" + login.getPassword() + "']/home_dir/text()"); Document d = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new File("db.xml")); String homedir = xlogin.evaluate(d); Assume that user "john" wishes to leverage XPath Injection and login without a valid password. By providing a username "john" and password "' or ''='" the XPath expression now becomes //users/user[login/text()='john' or ''='' and password/text() = '' or ''='']/home_dir/text()
which, of course, lets user "john" login without a valid password, thus bypassing authentication. This situation occurred due to the use of improperly filtered input and the use of dynamic XPath query. Parameterizng the XPath query provides a second line of defense, should input validation fail. The approach to parameterizing the query in Java is to use a resolver to resolve the bound parameters: public class LoginResolver implements XPathVariableResolver { Login login = null; public Object resolveVariable(QName variableName) { if (variableName == null) throw new NullPointerException("The variable name cannot be null"); if (variableName.equals(new QName("username"))) return new String(this.login.getUserName()); else if (variableName.equals(new QName("password"))) return new String(this.login.getPassword()); else return null; } public LoginResolver(Login login){ this.login = login; } } The corresponding XPath expression and query are: xpath.setXPathVariableResolver(new LoginResolver(login)); XPathExpression xlogin = xpath.compile("//users/user[login/text()=$username and password/text() = $password]/home_dir/text()"); Document d = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new File("db.xml")); String homedir = xlogin.evaluate(d); A similar attack pattern that seeks to extract information, including the XML document structure, is known as Blind XPath Injection and is based on the lack of proper input validation and non-parameterized XPath queries. The difference lies in the fact that bypassing authentication does not require knowledge of the rest of the document and the corresponding query can be quite easily discerned. With Blind XPath Injection, the attacker asks the database a number of Boolean questions by formulating appropriate XPath expressions. | | Injection Vector | User-controllable input used as part of dynamic XPath queries | | Payload | XPath expressions intended to defeat checks run by XPath queries | | Activation Zone | XML database | | Payload Activation Impact | The impact of payload activation is that it is interpreted as part of the XPath expression used in the query, thus enabling an attacker to modify the expression used by the query. | | Related Weaknesses | | CWE-ID | Weakness Name | Weakness Relationship Type |
|---|
| 91 | XML Injection (aka Blind XPath Injection) | Targeted | | 74 | Failure to Sanitize Data into a Different Plane (aka 'Injection') | Secondary | | 20 | Improper Input Validation | Secondary | | 390 | Detection of Error Condition Without Action | Secondary | | 713 | OWASP Top Ten 2007 Category A2 - Injection Flaws | Targeted | | 707 | Failure to Enforce that Messages or Data are Well-Formed | Targeted |
| | Relevant Security Requirements | Special characters in user-controllable input must be escaped before use by the application. Only use parameterized XPath expressions to query the XML database. Custom error pages must be used to handle exceptions such that they do not reveal any information about the architecture of the application or the database. | | Related Security Principles | - Reluctance to Trust
- Failing Securely
- Defense in Depth
| | Related Guidelines | - Never Use Input as Part of a Directive to any Internal Component
- Handle All Errors Safely
| | Purpose | Penetration Exploitation | | CIA Impact | | Confidentiality Impact | Integrity Impact | Availability Impact |
|---|
| High | High | Medium |
| | Technical Context | | Architectural Paradigm | Framework | Platform | Language |
|---|
| Client-Server | All | All | All |
| | References | CWE - XML Injection CWE - Input Validation CWE - Improper Error Handling | | Source | | Submission(s) |
|---|
| Submitter | Organization | Date | Comment |
|---|
| Chiradeep B Chhaya | | 2007-01-30 | Second Draft |
| Modification(s) |
|---|
| Modifier | Organization | Date | Comment |
|---|
| Malik Hamro | Cigital, Inc | 2007-02-27 | Reformat to new schema and review | | Sean Barnum | Cigital, Inc | 2007-03-05 | Review and revise |
|
| Attack Pattern ID | Pattern Abstraction: Detailed 85 | | Typical Severity | Very High | | Description | Summary This attack utilizes the frequent client-server roundtrips in Ajax conversation to scan a system. While Ajax does not open up new vulnerabilities per se, it does optimize them from an attacker point of view. In many XSS attacks the attacker must get a "hole in one" and successfully exploit the vulnerability on the victim side the first time, once the client is redirected the attacker has many chances to engage in follow on probes, but their is only one first chance. In a widely used web application this is not a major problem because 1 in a 1,000 is good enough in a widely used application.
A common first step for an attacker is to footprint the environment to understand what attacks will work. Since footprinting relies on enumeration, the conversational pattern of rapid, multiple requests and responses that are typical in Ajax applications enable an attacker to look for many vulnerabilities, well known ports, network locations and so on. | | Attack Prerequisites | The user must allow Javscript to execute in their browser | | Typical Likelihood of Exploit |
High
| | Methods of Attack | - Protocol Manipulation
- Injection
- Brute Force
| | Examples-Instances | Description Footprinting can be executed over almost any protocol including HTTP, TCP, UDP, and ICMP, with the general goal of gaining further information about a host environment to launch further attacks. By appending a malicious script to an otherwise normal looking URL, the attacker can probe the sysem for banners, vulnerabilities, filenames, available services, and in short anything the host process has access to. The results of the probe are either used to execute additional javascript (for example, if the attacker's footprint script identifies a vulnerability in a firewall permission, then the client side script executes a javascript to change client firewall settings, or an attacker may simply echo the results of the scan back out to a remote host for targeting future attacks). | | Attacker Skill or Knowledge Required | Medium: to land and launch a script on victim's machine with appropriate footprinting logic for enumerating services and vulnerabilities in Javascript | | Solutions and Mitigations | Design: Use browser technologies that do not allow client side scripting. Design: Utilize strict type, character, and encoding enforcement Implementation: Ensure all content that is delivered to client is sanitized against an acceptable content specification. Implementation: Perform input validation for all remote content. Implementation: Perform output validation for all remote content. Implementation: Disable scripting languages such as Javascript in browser Implementation: Patching software. There are many attack vectors for XSS on the client side and the server side. Many vulnerabilities are fixed in service packs for browser, web servers, and plug in technologies, staying current on patch release that deal with XSS countermeasures mitigates this. | | Attack Motivation-Consequences | | | Injection Vector | Payload delivered through standard communication protocols, such as Ajax application. | | Payload | Command(s) executed directly on host | | Activation Zone | Client machine and client network | | Payload Activation Impact | Enables attacker to execute probes against client system. | | Related Weaknesses | | CWE-ID | Weakness Name | Weakness Relationship Type |
|---|
| 79 | Failure to Preserve Web Page Structure (aka 'Cross-site Scripting') | Targeted | | 113 | Failure to Sanitize CRLF Sequences in HTTP Headers (aka 'HTTP Response Splitting') | Targeted | | 348 | Use of Less Trusted Source | Targeted | | 96 | Insufficient Control of Directives in Statically Saved Code (Static Code Injection) | Targeted | | 20 | Improper Input Validation | Targeted | | 116 | Improper Encoding or Escaping of Output | Targeted | | 184 | Incomplete Blacklist | Secondary | | 86 | Failure to Sanitize Invalid Characters in Identifiers in Web Pages | Secondary | | 712 | OWASP Top Ten 2007 Category A1 - Cross Site Scripting (XSS) | Targeted | | 692 | Incomplete Blacklist to Cross-Site Scripting | Targeted |
| | Purpose | Reconnaissance | | CIA Impact | | Confidentiality Impact | Integrity Impact | Availability Impact |
|---|
| High | Low | Low |
| | Technical Context | | Architectural Paradigm | Framework | Platform | Language |
|---|
| Client-Server | All | All | AJAX |
| | References | Shreeraj Shah, "Ajax footprinting for Web 2.0 applications", http://www.net-security.org/dl/articles/Ajax_fingerprinting.pdf | | Source | | Submission(s) |
|---|
| Submitter | Organization | Date | Comment |
|---|
| Gunnar Peterson | | 2007-02-28 | |
| Modification(s) |
|---|
| Modifier | Organization | Date | Comment |
|---|
| Sean Barnum | Cigital, Inc | 2007-03-07 | Review and revise |
|
| Attack Pattern ID | Pattern Abstraction: Detailed 86 | | Typical Severity | Very High | | Description | Summary An attack of this type exploits web applications that generate web content, such as links in a HTML page, based on unvalidated or improperly validated data submitted by other actors. XSS in HTTP Headers attacks target the HTTP headers which are hidden from most users and may not be validated by web applications. Attack Execution Flow Explore Spider: Using a browser or an automated tool, an attacker follows all public links on a web site. He records all the entry points (input) that becomes part of generated HTTP header (not only GET/POST/COOKIE, but also Content-Type, etc.) | Attack Step
Techniques |
|---|
| Description | Environments |
|---|
| Use a spidering tool to follow and record all links and analyze the web pages to find entry points. Make special note of any links that include parameters used in the HTTP headers. | env-Web | | Look for HTML meta tags that could be injectable | env-Web | | Use a proxy tool to record all links visited during a manual traversal of the web application. | env-Web | | Use a browser to manually explore the website and analyze how it is constructed. Many browsers' plugins are available to facilitate the analysis or automate the discovery. | env-Web |
| Indicators of
Susceptibility |
|---|
| ID | Type | Description | Environments |
|---|
| c86s1i1 | Positive | Web content is generated by the application and served to the browser based on user-controllable inputs. | env-Web | | c86s1i2 | Positive | HTTP header variables are used by the application or the browser (DOM) | env-Web | | c86s1i3 | Inconclusive | No HTTP variables appear to be used on the current page. Even though none appear, the web application may still use them if they are provided. | env-Web | | c86s1i4 | Negative | Applications that have only static pages or that simply present information without accepting input are unlikely to be susceptible. | env-Web |
| Outcome |
|---|
| ID | Type | Description |
|---|
| c86s1o1 | Success | A list of URLs, with their corresponding HTTP variables is created by the attacker. |
| Security
Controls |
|---|
| ID | Type | Description |
|---|
| c86s1sc1 | Detective | Monitor velocity of page fetching in web logs. Humans who view a page and select a link from it will click far slower and far less regularly than tools. Tools make requests very quickly and the requests are typically spaced apart regularly (e.g. 0.8 seconds between them). | | c86s1sc2 | Detective | Create links on some pages that are visually hidden from web browsers. Using IFRAMES, images, or other HTML techniques, the links can be hidden from web browsing humans, but visible to spiders and programs. A request for the page, then, becomes a good predictor of an automated tool probing the application. | | c86s1sc3 | Preventative | Use CAPTCHA to prevent the use of the application by an automated tool. | | c86s1sc4 | Preventative | Actively monitor the application and either deny or redirect requests from origins that appear to be automated. |
Experiment Probe identified potential entry points for XSS vulnerability: The attacker uses the entry points gathered in the "Explore" phase as a target list and injects various common script payloads to determine if an entry point actually represents a vulnerability and to characterize the extent to which the vulnerability can be exploited. He records all the responses from the server that include unmodified versions of his script.
The attacker tries also to inject extra-parameter to the HTTP request to see if they are reflected back in the web page or in the HTTP response. | Attack Step
Techniques |
|---|
| Description | Environments |
|---|
| Manually inject various script payloads into each identified entry point using a list of common script injection probes and observe system behavior to determine if script was executed. | env-Web | | Use an automated injection attack tool to inject various script payloads into each identified entry point using a list of common script injection probes and observe system behavior to determine if script was executed. | env-Web | | Use a proxy tool to record results of manual input of XSS probes in known URLs. | env-Web |
| Indicators of
Susceptibility |
|---|
| ID | Type | Description | Environments |
|---|
| c86s2i1 | Positive | User-controllable input is embedded as part of generated HTTP headers | env-Web | | c86s2i2 | Positive | Input parameters become part of the web page (even in meta tags) | env-Web | | c86s2i3 | Positive | Output to the browser is not encoded to remove executable scripting syntax. | env-Web | | c86s2i4 | Inconclusive | Nothing is returned to the web page. It may be a stored XSS. The unique identifier from the probe helps to trace the flow of the possible XSS. | env-Web |
| Outcomes |
|---|
| ID | Type | Description |
|---|
| c86s2o2 | Success | The attacker's cross-site scripting string is repeated back verbatim at some point in the web site (if not on the same page). Note that sometimes, the payload might be well encoded in the page, but wouldn't be encoded at all in some other section of the same web page (title, script, etc.) | | c86s2o1 | Failure | All HTML-sensitive characters are consistently re-encoded before being sent to the web browser. | | c86s2o3 | Inconclusive | Some sensitive characters are consistently encoded, but others are not. |
| Security
Controls |
|---|
| ID | Type | Description |
|---|
| c86s2sc1 | Detective | Monitor input to web servers (not only GET, but all in the inputs), application servers, and other HTTP infrastructure (e.g., load balancers). Alert on standard XSS probes. The majority of attackers use well known strings to check for vulnerabilities. Use the same vulnerability catalogs that hackers use. | | c86s2sc2 | Preventative | Apply appropriate input validation to filter all user-controllable input of scripting syntax | | c86s2sc3 | Preventative | Do not embed user-controllable input generated HTTP headers | | c86s2sc4 | Preventative | Actively monitor the application and either deny or redirect requests from origins that appear to be generating XSS probes. |
Exploit Steal session IDs, credentials, page content, etc.: As the attacker succeeds in exploiting the vulnerability, he can choose to steal user's credentials in order to reuse or to analyze them later on. | Attack Step
Techniques |
|---|
| Description | Environments |
|---|
| Develop malicious JavaScript that is injected through vectors identified during the Experiment Phase and loaded by the victim's browser and sends document information to the attacker. | env-Web | | Develop malicious JavaScript that injected through vectors identified during the Experiment Phase and takes commands from an attacker's server and then causes the browser to execute appropriately. | env-Web |
| Outcomes |
|---|
| ID | Type | Description |
|---|
| c86s3o1 | Success | The attacker gets the user's cookies or other session identifiers. | | c86s3o2 | Success | The attacker gets the content of the page the user is viewing. | | c86s3o3 | Success | The attacker causes the user's browser to visit a page with malicious content. |
| Security
Controls |
|---|
| ID | Type | Description |
|---|
| c86s3sc1 | Detective | Monitor server logs for scripting parameters. | | c86s3sc2 | Detective | Monitor server logs for referrers. If users are being tricked into clicking XSS links through forums or other web postings, their web browsers will be providing Referrer headers most of the time. These can help indicate that the actual request is illegitimate. | | c86s3sc3 | Preventative | Apply appropriate input validation to filter all user-controllable input of scripting syntax | | c86s3sc4 | Preventative | Appropriately encode all browser output to avoid scripting syntax | | c86s3sc5 | Preventative | Actively monitor the application and either deny or redirect requests from origins that appear to be generating XSS probes. |
Forceful browsing: When the attacker targets the current application or another one (through CSRF vulnerabilities), the user will then be the one who perform the attacks without being aware of it. These attacks are mostly targeting application logic flaws, but it can also be used to create a widespread attack against a particular website on the user's current network (Internet or not). | Attack Step
Techniques |
|---|
| Description | Environments |
|---|
| Develop malicious JavaScript that is injected through vectors identified during the Experiment Phase and loaded by the victim's browser and performs actions on the same web site | env-Web | | Develop malicious JavaScript that injected through vectors identified during the Experiment Phase and takes commands from an attacker's server and then causes the browser to execute request to other web sites (especially the web applications that have CSRF vulnerabilities). | env-Web |
| Outcomes |
|---|
| ID | Type | Description |
|---|
| c86s4o1 | Success | The attacker indirectly controls the user's browser and makes it performing actions exploiting CSRF. | | c86s4o2 | Success | The attacker manipulates the browser through the steps that he designed in his attack. The user, identified on a website, is now performing actions he is not aware of. |
| Security
Controls |
|---|
| ID | Type | Description |
|---|
| c86s4sc1 | Detective | Monitor server logs for scripting parameters. | | c86s4sc2 | Detective | Monitor server logs for referrers. If users are being tricked into clicking XSS links through forums or other web postings, their web browsers will be providing Referrer headers most of the time. These can help indicate that the actual request is illegitimate. | | c86s4sc3 | Preventative | Apply appropriate input validation to filter all user-controllable input of scripting syntax | | c86s4sc4 | Preventative | Appropriately encode all browser output to avoid scripting syntax | | c86s4sc5 | Preventative | Actively monitor the application and either deny or redirect requests from origins that appear to be generating XSS probes. |
Content spoofing: By manipulating the content, the attacker targets the information that the user would like to get from the website. | Attack Step
Technique |
|---|
| Description | Environments |
|---|
| Develop malicious JavaScript that is injected through vectors identified during the Experiment Phase and loaded by the victim's browser and exposes attacker-modified invalid information to the user on the current web page. | env-Web |
| Outcome |
|---|
| ID | Type | Description |
|---|
| c86s5o1 | Success | The user sees a page containing wrong information |
| Security
Controls |
|---|
| ID | Type | Description |
|---|
| c86s5sc1 | Detective | Monitor server logs for scripting parameters. | | c86s5sc2 | Detective | Monitor server logs for referrers. If users are being tricked into clicking XSS links through forums or other web postings, their web browsers will be providing Referrer headers most of the time. These can help indicate that the actual request is illegitimate. | | c86s5sc3 | Preventative | Apply appropriate input validation to filter all user-controllable input of scripting syntax | | c86s5sc4 | Preventative | Appropriately encode all browser output to avoid scripting syntax | | c86s5sc5 | Preventative | Actively monitor the application and either deny or redirect requests from origins that appear to be generating XSS probes. |
| | Attack Prerequisites | Target software must be a client that allows scripting communication from remote hosts, and attacker must control a remote site of some sort to redirect client and data to. | | Typical Likelihood of Exploit |
High
| | Methods of Attack | - Injection
- Modification of Resources
- Protocol Manipulation
| | Examples-Instances | Description Utilize a remote style sheet set in the HTTP header for XSS attack. When the attacker is able to point to a remote stylesheet, any of the variables set in that stylesheet are controllable on the client side by the remote attacker. Like most XSS attacks, results vary depending on browser that is used. (source:http://ha.ckers.org/xss.html) <META HTTP-EQUIV="Link" Content="<http://ha.ckers.org/xss.css>; REL=stylesheet"> Description Google's 404 redirection script was found vulnerable to this attack vector. Google's 404 file not found page read * Response headers: "Content-Type: text/html; charset=[encoding]". * Response body: <META http-equiv="Content-Type" (...) charset=[encoding]/> If the response sends an unexpected encoding type such as UTF-7, then no enforcement is done on the payload and arbitrary XSS code will be transported along with the standard HTTP response. Source: http://seclists.org/fulldisclosure/2005/Dec/1107.html Description XSS can be used in variety of ways, because it is scripted and executes in a distribtued, asynchronous fashion it can create its own vector and openings. For example, the attacker can use XSS to mount a DDoS attack by having series of different computers unknowingly executing requests against a single host. | | Attacker Skill or Knowledge Required | Low: To achieve a redirection and use of less trusted source, an attacker can simply edit HTTP Headers that are sent to client machine. High: Exploiting a client side vulnerability to inject malicious scripts into the browser's executable process. | | Resources Required | Ability to deploy a custom hostile service for access by targeted clients. Ability to communicate synchronously or asynchronously with client machine | | Solutions and Mitigations | Design: Use browser technologies that do not allow client side scripting. Design: Utilize strict type, character, and encoding enforcement Design: Server side developers should not proxy content via XHR or other means, if a http proxy for remote content is setup on the server side, the client's browser has no way of discerning where the data is originating from. Implementation: Ensure all content that is delivered to client is sanitized against an acceptable content specification. Implementation: Perform input validation for all remote content. Implementation: Perform output validation for all remote content. Implementation: Disable scripting languages such as Javascript in browser Implementation: Session tokens for specific host Implementation: Patching software. There are many attack vectors for XSS on the client side and the server side. Many vulnerabilities are fixed in service packs for browser, web servers, and plug in technologies, staying current on patch release that deal with XSS countermeasures mitigates this. | | Attack Motivation-Consequences | - Run Arbitrary Code
- Information Leakage
- Privilege Escalation
| | Context Description | "Attack Pattern: XSS in HTTP Headers
The HTTP headers of a request are always available to a server for consumption. No matter the context or where data are positioned., if the data are from the client, they should clearly be untrusted. However in many cases programmers overlook header information. For some reason header information is treated as holy ground that cannot be controlled by the user. This pattern takes advantage of this oversight to inject data via a header field. [Hoglund and McGraw 04]
.... Web 2.0 technologies rely heavily on mashups and other plug in technologies like multi media players which are effectively composed of content generated by other systems and are vulnerable due to the fact that an attacker may use the HTTP header information that these technologies consume and display as an attack launch pad.
Beyond Web 2.0, increasingly system administration software uses web front ends, from firewall administration to application servers, to blogging software, many tools are administered through web browsers. This gives the administrator the ability to administer in a highly distributed environment, but this comes at the cost of exposing the command and control software for the system to web attacks. Additionally, because the rich functionality required these administration applications, many rely on scripting languages. So an attacker can insert HTTP links into logs, audit functionality, error logs, and message queues, then, for example, a Javascript-enabled web browser with administrator rights can be redirected to execute a wide variety of attacks, including those listed here.
As with all remote attacks, it is important to differentiate the ability to launch an attack (such as probing an internal network for unpatched servers) and the ability of the remote attacker to collect and interpret the output of said attack. | | Injection Vector | Malicious input delivered through HTTP Headers. | | Payload | Varies with instantiation of attack pattern. In the case of HTTP headers they may not be visible to the end user via a browser | | Activation Zone | Header processing on the server or Client browser | | Payload Activation Impact | Enables attacker to execute scripts to launch attacks on server as well as remote client machine and environment | | Related Weaknesses | | CWE-ID | Weakness Name | Weakness Relationship Type |
|---|
| 79 | Failure to Preserve Web Page Structure (aka 'Cross-site Scripting') | Targeted | | 184 | Incomplete Blacklist | Secondary | | 348 | Use of Less Trusted Source | Targeted | | 96 | Insufficient Control of Directives in Statically Saved Code (Static Code Injection) | Targeted | | 20 | Improper Input Validation | Targeted | | 116 | Improper Encoding or Escaping of Output | Targeted | | 86 | Failure to Sanitize Invalid Characters in Identifiers in Web Pages | Secondary | | 692 | Incomplete Blacklist to Cross-Site Scripting | Targeted | | 697 | Insufficient Comparison | Targeted | | 713 | OWASP Top Ten 2007 Category A2 - Injection Flaws | Targeted | | 71 | Apple '.DS_Store' | Targeted |
| | Related Vulnerabilities | | Vulnerability-ID | Vulnerability Description |
|---|
|
CVE-2006-5442
|
Summary: ViewVC 1.0.2 and earlier does not specify a charset in its HTTP headers or HTML documents, which allows remote attackers to conduct cross-site scripting (XSS) attacks that inject arbitrary UTF-7 encoded JavaScript code via a view.
| |
CVE-2006-3918
|
Summary: http_protocol.c in (1) IBM HTTP Server 6.0 before 6.0.2.13 and 6.1 before 6.1.0.1, and (2) Apache HTTP Server 1.3 before 1.3.35, 2.0 before 2.0.58, and 2.2 before 2.2.2, does not sanitize the Expect header from an HTTP request when it is reflected back in an error message, which might allow cross-site scripting (XSS) style attacks using web client components that can send arbitrary headers in requests, as demonstrated using a Flash SWF file.
|
| | Purpose | Penetration Exploitation | | CIA Impact | | Confidentiality Impact | Integrity Impact | Availability Impact |
|---|
| High | High | High |
| | Technical Context | | Architectural Paradigm | Framework | Platform | Language |
|---|
| Client-Server | All | All | All |
| | References | G. Hoglund and G. McGraw. Exploiting Software: How to Break Code. Addison-Wesley, February 2004. | | Source | | Submission(s) |
|---|
| Submitter | Organization | Date | Comment |
|---|
| G. Hoglund and G. McGraw. Exploiting Software: How to Break Code. Addison-Wesley, February 2004. | Cigital, Inc | 2007-01-01 | |
| Modification(s) |
|---|
| Modifier | Organization | Date | Comment |
|---|
| Gunnar Peterson | Cigital, Inc | 2007-02-28 | Fleshed out content to CAPEC schema from the original descriptions in "Exploiting Software" | | Sean Barnum | Cigital, Inc | 2007-03-09 | Review and revise | | Richard Struse | VOXEM, Inc | 2007-03-26 | Review and feedback leading to changes in Name | | Sean Barnum | Cigital, Inc | 2007-04-16 | Modified pattern content according to review and feedback | | Romain Gaucher | Cigital, Inc | 2009-02-10 | Created draft content for detailed description | | Sean Barnum | Cigital Federal, Inc | 2009-04-13 | Reviewed and revised content for detailed description |
|
| Attack Pattern ID | Pattern Abstraction: Detailed 32 | | Typical Severity | High | | Description | Summary A variant of cross-site scripting called "reflected" cross-site scripting, the HTTP Query Strings attack consists of passing a malicious script inside an otherwise valid HTTP request query string. This is of significant concern for sites that rely on dynamic, user-generated content such as bulletin boards, news sites, blogs, and web enabled administration GUIs. The malicious script may steal session data, browse history, probe files, or otherwise execute attacks on the client side. Once the attacker has prepared the malicious HTTP query it is sent to a victim user (perhaps by email, IM, or posted on an online forum), who clicks on a normal looking link that contains a poison query string. This technique can be made more effective through the use of services like http://tinyurl.com/, which makes very small URLs that will redirect to very large, complex ones. The victim will not know what he is really clicking on. Attack Execution Flow Explore Spider: Using a browser or an automated tool, an attacker follows all public links on a web site. He records all the links he finds. | Attack Step
Techniques |
|---|
| Description | Environments |
|---|
| Use a spidering tool to follow and record all links. Make special note of any links that include parameters in the URL. | env-Web | | Use a proxy tool to record all links visited during a manual traversal of the web application. Make special note of any links that include parameters in the URL. Manual traversal of this type is frequently necessary to identify forms that are GET method forms rather than POST forms. | env-Web | | Use a browser to manually explore the website and analyze how it is constructed. Many browser's plugins are available to facilitate the analysis or automate the URL discovery. | env-Web |
| Indicators of
Susceptibility |
|---|
| ID | Type | Description | Environments |
|---|
| c32s1i1 | Positive | URL parameters are used by the application or the browser (DOM) | env-Web | | c32s1i2 | Inconclusive | Using URL rewriting, parameters may be part of the URL path. | env-Web | | c32s1i3 | Inconclusive | No parameters appear on the URL. Even though none appear, the web application may still use them if they are provided. | env-Web | | c32s1i4 | Inconclusive | Application could use POST variable as GET inside the application. Therefore, looking for POST parameters and adding them to the query string. | env-Web | | c32s1i5 | Negative | Applications that have only static pages or that simply present information without accepting input are unlikely to be susceptible. | env-Web |
| Outcome |
|---|
| ID | Type | Description |
|---|
| c32s1o1 | Success | A list of URLs, with their corresponding parameters is created by the attacker. |
| Security
Controls |
|---|
| ID | Type | Description |
|---|
| c32s1sc1 | Detective | Monitor velocity of page fetching in web logs. Humans who view a page and select a link from it will click far slower and far less regularly than tools. Tools make requests very quickly and the requests are typically spaced apart regularly (e.g. 0.8 seconds between them). | | c32s1sc2 | Detective | Create links on some pages that are visually hidden from web browsers. Using IFRAMES, images, or other HTML techniques, the links can be hidden from web browsing humans, but visible to spiders and programs. A request for the page, then, becomes a good predictor of an automated tool probing the application. | | c32s1sc3 | Preventative | Use CAPTCHA to prevent the use of the application by an automated tool. | | c32s1sc4 | Preventative | Actively monitor the application and either deny or redirect requests from origins that appear to be automated. |
Experiment Attempt variations on input parameters: Possibly using an automated tool, an attacker requests variations on the URLs he spidered before. He sends parameters that include variations of payloads. He records all the responses from the server that include unmodified versions of his script. | Attack Step
Techniques |
|---|
| Description | Environments |
|---|
| Use a list of XSS probe strings to inject in parameters of known URLs. If possible, the probe strings contain a unique identifier. | env-Web | | Use a proxy tool to record results of manual input of XSS probes in known URLs. | env-Web |
| Indicators of
Susceptibility |
|---|
| ID | Type | Description | Environments |
|---|
| c32s2i1 | Positive | The output of pages includes some form of a URL parameter. E.g., ?error="File not Found" becomes "File not Found" in the title of the web page. | env-Web | | c32s2i2 | Positive | Input parameters become part of JavaScript, VBScript, or other script in a web page. | env-Web | | c32s2i3 | Inconclusive | Nothing is returned to the web page. It may be a stored XSS. The unique identifier from the probe helps to trace the flow of the possible XSS. | env-Web |
| Outcomes |
|---|
| ID | Type | Description |
|---|
| c32s2o1 | Success | The attacker's cross-site scripting string is repeated back verbatim at some point in the web site (if not on the same page). Note that sometimes, the payload might be well encoded in the page, but wouldn't be encoded at all in some other section of the same web page (title, script, etc.) | | c32s2o2 | Failure | All HTML-sensitive characters are consistently re-encoded before being sent to the web browser. | | c32s2o3 | Inconclusive | Some sensitive characters are consistently encoded, but others are not. |
| Security
Controls |
|---|
| ID | Type | Description |
|---|
| c32s2sc1 | Detective | Monitor input to web servers, application servers, and other HTTP infrastructure (e.g., load balancers). Alert on standard XSS probes. The majority of attackers use well known strings to check for vulnerabilities. Use the same vulnerability catalogs that hackers use. | | c32s2sc2 | Preventative | Apply appropriate input validation to filter all user-controllable input of scripting syntax | | c32s2sc3 | Preventative | Do not embed user-controllable input generated HTTP headers | | c32s2sc4 | Preventative | Actively monitor the application and either deny or redirect requests from origins that appear to be generating XSS probes. |
Exploit Steal session IDs, credentials, page content, etc.: As the attacker succeeds in exploiting the vulnerability, he can choose to steal user's credentials in order to reuse or to analyze them later on. | Attack Step
Techniques |
|---|
| Description | Environments |
|---|
| Develop malicious JavaScript that is injected through vectors identified during the Experiment Phase and loaded by the victim's browser and sends document information to the attacker. | env-Web | | Develop malicious JavaScript that injected through vectors identified during the Experiment Phase and takes commands from an attacker's server and then causes the browser to execute appropriately. | env-Web |
| Outcomes |
|---|
| ID | Type | Description |
|---|
| c32s3o1 | Success | The attacker gets the user's cookies or other session identifiers. | | c32s3o2 | Success | The attacker gets the content of the page the user is viewing. | | c32s3o3 | Success | The attacker causes the user's browser to visit a page with malicious content. |
| Security
Controls |
|---|
| ID | Type | Description |
|---|
| c32s3sc1 | Detective | Monitor server logs for scripting parameters. | | c32s3sc2 | Detective | Monitor server logs for referrers. If users are being tricked into clicking XSS links through forums or other web postings, their web browsers will be providing Referrer headers most of the time. These can help indicate that the actual request is illegitimate. | | c32s3sc3 | Preventative | Apply appropriate input validation to filter all user-controllable input of scripting syntax | | c32s3sc4 | Preventative | Appropriately encode all browser output to avoid scripting syntax | | c32s3sc5 | Preventative | Actively monitor the application and either deny or redirect requests from origins that appear to be generating XSS probes. |
Forceful browsing: When the attacker targets the current application or another one (through CSRF vulnerabilities), the user will then be the one who perform the attacks without being aware of it. These attacks are mostly targeting application logic flaws, but it can also be used to create a widespread attack against a particular website on the user's current network (Internet or not). | Attack Step
Techniques |
|---|
| Description | Environments |
|---|
| Develop malicious JavaScript that is injected through vectors identified during the Experiment Phase and loaded by the victim's browser and performs actions on the same web site | env-Web | | Develop malicious JavaScript that injected through vectors identified during the Experiment Phase and takes commands from an attacker's server and then causes the browser to execute request to other web sites (especially the web applications that have CSRF vulnerabilities). | env-Web |
| Outcomes |
|---|
| ID | Type | Description |
|---|
| c32s4o1 | Success | The attacker indirectly controls the user's browser and makes it performing actions exploiting CSRF. | | c32s4o2 | Success | The attacker manipulates the browser through the steps that he designed in his attack. The user, identified on a website, is now performing actions he is not aware of. |
| Security
Controls |
|---|
| ID | Type | Description |
|---|
| c32s4sc1 | Detective | Monitor server logs for scripting parameters. | | c32s4sc2 | Detective | Monitor server logs for referrers. If users are being tricked into clicking XSS links through forums or other web postings, their web browsers will be providing Referrer headers most of the time. These can help indicate that the actual request is illegitimate. | | c32s4sc3 | Preventative | Apply appropriate input validation to filter all user-controllable input of scripting syntax | | c32s4sc4 | Preventative | Appropriately encode all browser output to avoid scripting syntax | | c32s4sc5 | Preventative | Actively monitor the application and either deny or redirect requests from origins that appear to be generating XSS probes. |
Content spoofing: By manipulating the content, the attacker targets the information that the user would like to get from the website. | Attack Step
Technique |
|---|
| Description | Environments |
|---|
| Develop malicious JavaScript that is injected through vectors identified during the Experiment Phase and loaded by the victim's browser and exposes attacker-modified invalid information to the user on the current web page. | env-Web |
| Outcome |
|---|
| ID | Type | Description |
|---|
| c32s5o1 | Success | The user sees a page containing wrong information |
| Security
Controls |
|---|
| ID | Type | Description |
|---|
| c32s5sc1 | Detective | Monitor server logs for scripting parameters. | | c32s5sc2 | Detective | Monitor server logs for referrers. If users are being tricked into clicking XSS links through forums or other web postings, their web browsers will be providing Referrer headers most of the time. These can help indicate that the actual request is illegitimate. | | c32s5sc3 | Preventative | Apply appropriate input validation to filter all user-controllable input of scripting syntax | | c32s5sc4 | Preventative | Appropriately encode all browser output to avoid scripting syntax | | c32s5sc5 | Preventative | Actively monitor the application and either deny or redirect requests from origins that appear to be generating XSS probes. |
| | Attack Prerequisites | Target client software must allow scripting such as Javascript. Server software must allow display of remote generated HTML without sufficient input or output validation. | | Typical Likelihood of Exploit |
High
| | Methods of Attack | - Injection
- Protocol Manipulation
| | Examples-Instances | Description http://user:host@example.com:8080/oradb<script>alert('Hi')</script> Description Web applications that accept name value pairs in a HTTP Query string are inherently at risk to any value (or name for that matter) that an attacker would like to enter in the query string. This can be done manually via web browser or trivially scripted to post the query string to multiple sites. In the latter case, in the instance of many sites using similar infrastructure with predictable http queries being accepted and operated on (such as blogging software, Google applications, and so on), a single malicious payload can be scritped to target a wide variety of sites.
Web 2.0 type sites like Technorati and del.icio.us rely on user generated content like tags to build http links that are displayed to other users. del.icio.us allows users to identify sites, tag them with metadata and provide URL, descriptions and more data. This data is then echoed back to any other web browser that is interested in the link. If the data is not validated by the del.icio.us site properly then an abritrary code can be added into the standard http string sent to del.icio.us by the attacker, for example formatted as normal content with a URL and description and tagged as Java, and available to be clicked on (and executed by) any user browsing for Java content that clicks on this trojaned content. | | Attacker Skill or Knowledge Required | Low: To place malicious payload on server via HTTP High: Exploiting any information gathered by HTTP Query on script host | | Resources Required | Ability to send HTTP post to scripting host and collect output | | Solutions and Mitigations | Design: Use browser technologies that do not allow client side scripting. Design: Utilize strict type, character, and encoding enforcement Design: Server side developers should not proxy content via XHR or other means, if a http proxy for remote content is setup on the server side, the client's browser has no way of discerning where the data is originating from. Implementation: Ensure all content that is delivered to client is sanitized against an acceptable content specification. Implementation: Perform input validation for all remote content, including remote and user-generated content Implementation: Perform output validation for all remote content. Implementation: Disable scripting languages such as Javascript in browser Implementation: Session tokens for specific host Implementation: Patching software. There are many attack vectors for XSS on the client side and the server side. Many vulnerabilities are fixed in service packs for browser, web servers, and plug in technologies, staying current on patch release that deal with XSS countermeasures mitigates this. Implementation: Privileges are constrained, if a script is loaded, ensure system runs in chroot jail or other limited authority mode | | Attack Motivation-Consequences | - Information Leakage
- Run Arbitrary Code
| | Context Description | "Attack Pattern: HTTP Query Strings
A query string takes variable = value pairs. These are passed to the target executable or script designated in the request. A variable can be injected with script. The script is processed and stored in a way that is later visible to a user." [Hoglund and McGraw 04] | | Injection Vector | Script delivered through standard web server, such as a web server with user-generated content. | | Payload | HTTP Request Query String | | Activation Zone | Client web browser where script is executed | | Payload Activation Impact | Client web browser may be used to steal session data, passwords, cookies, and other tokens. | | Related Weaknesses | | CWE-ID | Weakness Name | Weakness Relationship Type |
|---|
| 79 | Failure to Preserve Web Page Structure (aka 'Cross-site Scripting') | Targeted | | 84 | Failure to Resolve Encoded URI Schemes in a Web Page | Targeted | | 85 | Doubled Character XSS Manipulations | Targeted | | 20 | Improper Input Validation | Targeted | | 86 | Failure to Sanitize Invalid Characters in Identifiers in Web Pages | Targeted | |
|
|