SQL Injection through SOAP Parameter Tampering
Attack Pattern ID: 110 (Standard Attack Pattern Completeness: Complete)Typical Severity: Very HighStatus: Draft
+ Description

Summary

An attacker modifies the parameters of the SOAP message that is sent from the service consumer to the service provider to initiate a SQL injection attack. On the service provider side, the SOAP message is parsed and parameters are not properly validated before being used to access a database in a way that does not use parameter binding, thus enabling the attacker to control the structure of the executed SQL query. This pattern describes a SQL injection attack with the delivery mechanism being a SOAP message.

Attack Execution Flow

Explore
  1. Detect Incorrect SOAP Parameter Handling:

    The attacker tampers with the SOAP message parameters and looks for indications that the tampering caused a change in behavior of the targeted application.

    Attack Step Techniques

    IDAttack Step Technique DescriptionEnvironments
    1

    The attacker tampers with the SOAP message parameters by injecting some special characters such as single quotes, double quotes, semi columns, etc. The attacker observes system behavior.

    env-Web

    Indicators

    IDtypeIndicator DescriptionEnvironments
    1Positive

    SOAP messages are used as a communication mechanism in the system

    env-Web

    Outcomes

    IDtypeOutcome Description
    1Success
    Any indication that the injected input is causing system trouble (e.g. stack traces are produced, the system does not respond, etc.) then the attacker may come to conclude that the system is vulnerable to SQL injection through SOAP parameter tampering.
Experiment
  1. Probe for SQL Injection vulernability:

    The attacker injects SQL syntax into vulnerable SOAP parameters identified during the Explore phase to search for unfiltered execution of the SQL syntax in a query.

    Indicators

    IDtypeIndicator DescriptionEnvironments
    1Negative

    Attacker receives normal response from server.

    env-Web env-ClientServer env-Peer2Peer env-CommProtocol
    2Positive

    Attacker receives an error message from server indicating that there was a problem with the SQL query.

    env-Web env-ClientServer env-Peer2Peer env-CommProtocol
    3Negative

    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

    IDtypeOutcome Description
    1Success
    At least one SOAP parameter susceptible to injection found.
    2Failure
    No SOAP parameter susceptible to injection found.

    Security Controls

    IDtypeSecurity Control Description
    1Detective
    Search for and alert on unexpected SQL keywords in application logs (e.g. SELECT, DROP, etc.).
    2Preventative
    Input validation of SOAP parameter data before including it in a SQL query
    3Preventative
    Use parameterized queries (e.g. PreparedStatement in Java, and Command.Parameters.Add() to set query parameters in .NET)
Exploit
  1. SecurityDatabase\Alert\Inject SQL via SOAP Parameters:

    The attacker injects SQL via SOAP parameters identified as vulnerable during Explore phase to launch a first or second order SQL injection attack.

    Attack Step Techniques

    IDAttack Step Technique DescriptionEnvironments
    1

    An attacker performs a SQL injection attack via the usual methods leveraging SOAP parameters as the injection vector. An attacker has to be careful not to break the XML parser at the service provider which may prevent the payload getting through to the SQL query. The attacker may also look at the WSDL for the web service (if available) to better understand what is expected by the service provider.

    env-Web

    Outcomes

    IDtypeOutcome Description
    1Success
    Attacker achieves goal of unauthorized system access, denial of service, etc.
    2Failure
    Attacker unable to exploit SQL Injection vulnerability.
+ Attack Prerequisites

SOAP messages are used as a communication mechanism in the system

SOAP parameters are not properly validated at the service provider

The service provider does not properly utilize parameter binding when building SQL queries

+ Typical Likelihood of Exploit

Likelihood: High

+ Methods of Attack
  • Injection
  • Analysis
+ Examples-Instances

Description

An attacker uses a travel booking system that leverages SOAP communication between the client and the travel booking service. An attacker begins to tamper with the outgoing SOAP messages by modifying their parameters to include characters that would break a dynamically constructed SQL query. He notices that the system fails to respond when these malicious inputs are injected in certain parameters transffered in a SOAP message. The attacker crafts a SQL query that modifies his payment amount in the travel system's database and passes it as one of the parameters . A backend batch payment system later fetches the payment amount from the database (the modified payment amount) and sends to the credit card processor, enabling the attacker to purchase the airfare at a lower price. An attacker needs to have some knowledge of the system's database, perhaps by exploiting another weakness that results in information disclosure.

+ Attacker Skills or Knowledge Required

Skill or Knowledge Level: Medium

If the attacker is able to gain good understanding of the system's database schema; High: If the attacker has to perform SQL injection blindly

+ Resources Required

No specialized hardware resources are required

+ Probing Techniques

SecurityDatabase\Alert\Inject SQL characters in SOAP parameters and observe system behavior

Review WSDL to understand what is expected by the service provider

+ Solutions and Mitigations

Properly validate and sanitize/reject user input at the service provider.

Ensure that prepared statements or other mechanism that enables parameter binding is used when accessing the database in a way that would prevent the attacker's supplied data from controlling the structure of the executed query.

At the database level, ensure that the database user used by the application in a particular context has the minimum needed privileges to the database that are needed to perform the operation. When possible, run queries against pregenerated views rather than the tables directly.

+ Attack Motivation-Consequences
  • Data Modification
  • Denial of Service
  • Information Leakage
  • Privilege Escalation
  • Run Arbitrary Code
+ Related Weaknesses
CWE-IDWeakness NameWeakness Relationship Type
89Improper Sanitization of Special Elements used in an SQL Command ('SQL Injection')Targeted
20Improper Input ValidationSecondary
+ Related Attack Patterns
NatureTypeIDNameDescriptionView(s) this relationship pertains toView\(s\)
ChildOfAttack PatternAttack Pattern7Blind SQL Injection 
Mechanism of Attack (primary)1000
ChildOfAttack PatternAttack Pattern66SQL Injection 
Mechanism of Attack (primary)1000
ChildOfAttack PatternAttack Pattern280SOAP Parameter Tampering 
Mechanism of Attack (primary)1000
+ Relevant Security Requirements

Always safely access the database through prepared statements that leverage parameter binding

Properly validate all SOAP parameters to ensure that their values are as expected

Reject bad user input (do not try to sanitize it)

+ Related Security Principles
  • Defense in Depth

  • Least Privilege

+ Related Guidelines
  • Remember that the client can be made invisible

+ Purposes
  • Exploitation
+ CIA Impact
Confidentiality Impact: HighIntegrity Impact: HighAvailability Impact: High
+ Technical Context
Architectural Paradigms
SOA
Frameworks
All
Platforms
All
Languages
All
+ Content History
Submissions
SubmitterOrganizationDateComments
Evgeny LebanidzeCigital, Inc2008-01-12Initial core pattern content
Modifications
ModifierOrganizationDateComments
Sean BarnumCigital Federal, Inc.2009-04-20Refinement of pattern content