Web Application Hacking · Topic 6 of 8
Web Services, APIs, Webhooks, Web Shells and Web App Security
Attacks on SOAP and REST web services, API and webhook risks, what a web shell is and how to find it, and the controls that secure a web application.
- 5 min
- SOAP uses XML and a WSDL. REST uses HTTP with JSON or XML.
- Broken object level authorization leads the OWASP API list.
- Verify webhook signatures and timestamps.
What it is
A web service lets programs talk to each other over the web. An application programming interface (API) is the set of calls a program exposes. A webhook is the reverse: a server sends an HTTP request to a registered address when an event occurs.
A web shell is a malicious script placed on a web server that gives an attacker remote control. The page ends with the controls that secure a web application as a whole.
How it works
Attack web services
| Style | Format | Notes |
|---|---|---|
| SOAP | XML messages, described by a WSDL file | Uses WS-Security for message level protection |
| REST | HTTP with JSON or XML | Resources identified by URLs, standard HTTP methods |
Typical attacks include:
- Reconnaissance: the WSDL file lists every operation and parameter, so an exposed WSDL is a map for the attacker.
- XML injection and XXE: malformed or malicious XML sent to a parser.
- SOAP action spoofing and parameter tampering: altering operation names or values.
- Injection: SQL, command or XPath injection through service parameters.
- Replay and man in the middle: capturing and resending valid messages.
- Denial of service: very large or deeply nested XML.
- Authentication flaws: weak keys, missing tokens or accepting unsigned messages.
Defenses: validate messages against a schema, disable external entities, require authentication and signed messages, use TLS, restrict who can read the WSDL, and rate limit.
Web API threats
APIs expose data directly, so authorization flaws are the most serious. The OWASP API Security Top 10 starts with broken object level authorization, which is the API form of IDOR. Other common issues:
| Issue | Description |
|---|---|
| Broken authentication | Weak tokens, keys sent in URLs, no expiry |
| Broken object level authorization | Changing an object ID returns another user's data |
| Excessive data exposure | The API returns more fields than the client needs |
| Mass assignment | The API binds client supplied fields to internal properties, so users set fields such as role |
| Lack of rate limiting | Allows brute force and resource exhaustion |
| Injection | Unsanitized input reaching a database or interpreter |
| Improper inventory | Old or undocumented API versions left running |
GraphQL and REST APIs are tested with an intercepting proxy or tools such as Postman and Burp Suite. Defenses are strong token authentication (OAuth 2.0 and JWT with signature validation), authorization on every object, returning only needed fields, schema validation, rate limits and an API inventory.
Webhooks
A webhook posts event data to a URL the receiver provides. Risks and fixes:
- Spoofed callbacks: an attacker posts fake events. Verify a shared secret signature (an HMAC of the body) on every request.
- Replay: include and check a timestamp or unique ID.
- Server side request forgery: if users supply the webhook URL, the server may be tricked into calling internal addresses. Validate destinations and block internal ranges.
- Data exposure: sending sensitive data over plain HTTP. Use HTTPS only.
Web shells
A web shell is a script (in PHP, ASP.NET, JSP or similar) uploaded to a server, which gives the attacker a browser based interface to run commands, browse files and move deeper. It is usually installed through a file upload flaw, an injection or a stolen credential. China Chopper is a well known small example.
Detection: file integrity monitoring and comparing the web root with a known good copy, scanning for suspicious functions that run commands, unusual new files in upload folders, unexpected outbound connections, and web logs showing requests to one odd file. Prevention: validate and restrict uploads, store uploads outside the web root, disable script execution in upload folders, patch, and run the server with low privilege.
Web application security
| Control | Purpose |
|---|---|
| Secure development lifecycle | Security in design, code review and testing |
| Input validation and output encoding | Stop injection and XSS |
| Parameterized queries | Separate data from commands |
| Strong authentication and session management | MFA, secure cookies, timeouts |
| Authorization on the server | Deny by default |
| Web application firewall | Filters known attack patterns |
| Security headers | CSP, HSTS, X-Frame-Options |
| Patch and dependency management | Fix vulnerable components |
| Logging, monitoring and testing | SAST, DAST, penetration tests |
Tools worth knowing: OWASP ZAP and Burp Suite for dynamic testing, ModSecurity as an open source WAF engine, and dependency checkers for vulnerable libraries.
A worked example
An image upload accepts any file and stores it in a public folder. Later requests to a single new .php file arrive and the server starts connecting to an unknown address. The upload flaw let an attacker install a web shell. The remedy is to remove the file, check what ran, restrict uploads by type and content, and stop script execution in that folder.
How the exam asks about this
- "Which file describes a SOAP service's operations and may help an attacker map it?" -> The WSDL file.
- "An API returns another user's record when the ID is changed. Which API risk?" -> Broken object level authorization.
- "A script uploaded to a server that gives remote command access is called what?" -> A web shell.
What to remember for the exam
- SOAP uses XML and a WSDL. REST uses HTTP with JSON or XML.
- Broken object level authorization leads the OWASP API list.
- Verify webhook signatures and timestamps.
- Web shells arrive through upload flaws and are found with file integrity monitoring.
- Layered web app security: secure design, validation, WAF, patching and testing.
A WAF is a safety net, not a fix. The application should still validate input and enforce authorization itself.
Common mistakes
Thinking APIs are safer because there is no browser. They face the same attacks.
Skipping authorization because the client hides the option. Attackers call the API directly.
Allowing uploads into an executable folder. It turns a file upload into code execution.
Check yourself
What does a webhook receiver check to confirm the sender?
A signature (HMAC) made with a shared secret, plus a timestamp to prevent replay.
Why is an exposed WSDL a risk?
It lists operations and parameters, which helps attackers find what to test.
How can uploads be made safer?
Restrict type and content, store them outside the web root and disable script execution there.
Topic 6 of 8 in Web Application Hacking
Test yourself on Web Application Hacking
The full EC-Council 312-50 question bank has 1,000 questions, with timed practice exams and an explanation for every answer.
This study guide is independent and is not affiliated with, endorsed by, or sponsored by EC-Council. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.