Esoteric Web Application Vulnerabilities
Andres Riancho
BruCON 0x08 · Day 1
Overview
In this insightful BruCON talk, security expert Andres Riancho delves into "esoteric web application vulnerabilities"—complex, subtle, and often challenging-to-identify flaws that represent the next frontier in application security. Riancho, known for his work on the open-source web application security scanner w3af, argues that the landscape of web vulnerabilities is rapidly evolving. Traditional, common issues like SQL Injection and Cross-Site Scripting (XSS) are becoming less prevalent due to the widespread adoption of modern development frameworks (e.g., Ruby on Rails, Django) that incorporate robust built-in protections like Object-Relational Mappers (ORMs) and secure templating engines.

Key moments
- 1:00 Why common web vulnerabilities are disappearing
- 8:00 NoSQL injection from aggressive input decoding
- 18:00 Bypassing two-factor authentication via callback URL
- 25:00 Password reset vulnerability using a NULL token
- 37:00 PayPal IPN double spend due to missing verification
- 47:00 Remote Code Execution via ActiveSupport MessageVerifier
- 49:50 Why security professionals should focus on complex vulnerabilities
Esoteric Web Application Vulnerabilities
Speakers: Andres Riancho
Conference: BruCON
YouTube: https://www.youtube.com/watch?v=V8_Ozpl_eyo
Overview
In this insightful BruCON talk, security expert Andres Riancho delves into "esoteric web application vulnerabilities"—complex, subtle, and often challenging-to-identify flaws that represent the next frontier in application security. Riancho, known for his work on the open-source web application security scanner w3af, argues that the landscape of web vulnerabilities is rapidly evolving. Traditional, common issues like SQL Injection and Cross-Site Scripting (XSS) are becoming less prevalent due to the widespread adoption of modern development frameworks (e.g., Ruby on Rails, Django) that incorporate robust built-in protections like Object-Relational Mappers (ORMs) and secure templating engines.
This shift necessitates a change in how security professionals approach web application assessments. Instead of relying on automated tools for "boring" vulnerabilities, Riancho advocates for leveraging human intellect and source code review to uncover deeper, more intricate flaws that frameworks don't inherently prevent. The talk meticulously walks through five distinct, real-world vulnerabilities, demonstrating how seemingly innocuous features or common integration patterns can lead to severe security breaches, including account compromise and remote code execution. Riancho's presentation serves as a call to action for security practitioners to sharpen their skills and focus on the analytical challenges that lie beyond the capabilities of automated scanners.
Background
▶ Watch: Why common web vulnerabilities are disappearing (1:00)
The core premise of Riancho's talk is that the "golden age" of easily discoverable, high-impact SQL Injection and Cross-Site Scripting vulnerabilities is drawing to a close. Modern web development frameworks have significantly raised the baseline of security by abstracting away common pitfalls. For instance, Object-Relational Mappers (ORMs), used extensively in frameworks like Ruby on Rails and Django, encourage developers to interact with databases using object-oriented syntax rather than raw SQL queries. This approach inherently sanitizes input and prevents the vast majority of SQL Injection attacks. Similarly, templating engines in these frameworks often default to HTML encoding output, effectively neutralizing many XSS vectors unless developers explicitly opt out of these protections.
While this progress is beneficial for the overall security posture of new applications, it presents a challenge for security professionals. If automated tools can detect the dwindling number of common vulnerabilities, what remains for human experts? Riancho contends that the answer lies in understanding the complex interactions between application logic, framework features, and third-party integrations. These "esoteric" vulnerabilities arise not from a lack of basic input validation, but from unexpected interpretations of input, misconfigurations, or flawed assumptions in API designs. They require a deeper understanding of the application's unique business logic and underlying technical stack, making source code review an indispensable tool for their discovery.
Key Findings
▶ Watch: Bypassing two-factor authentication via callback URL (18:00)
Andres Riancho presents five distinct categories of "esoteric" web application vulnerabilities, each illustrating a different facet of complex security flaws that bypass typical protections:
- Aggressive Input Decoding Leading to NoSQL Injection: This vulnerability highlights how modern frameworks, particularly Ruby on Rails, can aggressively decode HTTP request parameters into complex data structures (like hashes) even when a simple string is expected. When combined with NoSQL database drivers (e.g., Mongoid for MongoDB) that interpret these structures as query operators, it can bypass authentication or authorization checks.
- Two-Factor Authentication (2FA) Bypass via Call-back URL Manipulation: This flaw demonstrates how an application's reliance on the HTTP
Hostheader to construct sensitive callback URLs, coupled with misconfigured web servers (e.g., Nginx, Django'sALLOWED_HOSTS), can lead to Server-Side Request Forgery (SSRF) and allow an attacker to intercept sensitive information, such as 2FA codes delivered via phone calls. - Password Reset Bypass via Null Token: Riancho reveals a subtle vulnerability in password reset implementations where the default
nilorNULLvalue for a password reset token in the database, combined with aggressive input decoding, allows an attacker to query for users with aNULLtoken. This effectively resets the password for the first such user in the database, enabling account takeover and, through chaining, compromise of multiple accounts. - Double Spend via PayPal IPN Handler Misconfiguration: This critical finding exposes a flaw in how merchants often integrate with payment gateways like PayPal using Instant Payment Notifications (IPN). If the merchant's IPN handler fails to verify the
receiver_emailparameter, an attacker can relay their own legitimate PayPal payment notifications to the merchant, tricking the merchant into crediting the attacker's account for goods or services without actual payment to the merchant. - Ruby on Rails
ActiveSupport::MessageVerifierRemote Code Execution (RCE): The final vulnerability showcases a dangerous default behavior in Rails' message signing utility. By default,MessageVerifieruses Ruby's insecureMarshalmodule for serialization. If an attacker can obtain the application's secret key, they can craft a malicious serialized object (gadget) that, when deserialized by the application, leads to arbitrary remote code execution.
These findings collectively underscore the importance of deep technical understanding, source code review, and a critical eye for how different components of a web application interact.
Technical Deep Dive
▶ Watch: Password reset vulnerability using a NULL token (25:00)
Riancho provides detailed technical breakdowns for each vulnerability:
1. Aggressive Input Decoding & NoSQL Injection
The first vulnerability hinges on how web frameworks, specifically Ruby on Rails, handle incoming HTTP parameters. Rails' params object is designed to be highly flexible, aggregating input from various sources like URL-encoded forms, JSON bodies, and query strings. A key feature is its ability to parse structured input. For example, if a developer expects a string name, but an attacker sends name[key]=value in a URL-encoded form or {"name": {"key": "value"}} in a JSON body, Rails will interpret name as a hash (a Ruby object similar to a dictionary) rather than a simple string.
This becomes problematic when interacting with NoSQL databases like MongoDB, particularly through an Object-Document Mapper (ODM) like Mongoid. Mongoid allows developers to query documents using object-oriented syntax, much like an ORM for SQL. A common query might look like Registration.where(user: user_id, confirmation_token: token). MongoDB supports powerful query operators (e.g., $ne for "not equals", $in for "in a list", $gt for "greater than").
The exploit combines these two features:
- The attacker sends a request where the
confirmation_tokenparameter is crafted as a hash containing a NoSQL operator, for example,{"$ne": "some_impossible_value"}. - Rails' aggressive input decoding parses this into a Ruby hash.
- Mongoid then receives this hash for the
confirmation_tokenfield in thewhereclause. Instead of treating it as a literal string to match, it interprets{"$ne": "some_impossible_value"}as a MongoDB query operator. - The query effectively becomes "find a registration where the user ID matches AND the confirmation token is NOT 'some_impossible_value'". Since "some_impossible_value" is unlikely to be any real token, this
WHEREclause condition often evaluates to true for any token, thus bypassing the intended token verification. This allows an attacker to complete actions, like registration, without possessing the legitimate token.
2. 2FA Bypass via Call-back URL Manipulation
This vulnerability targets a common pattern of integrating with third-party services, illustrated with a two-factor authentication system using phone calls. The application outsources the actual phone call to a Software-as-a-Service (SaaS) provider like Twilio. The process is:
- User requests phone verification.
- Vulnerable application calls Twilio's API, providing the user's phone number and a callback URL where Twilio should fetch the audio message to play during the call.
- Twilio makes an HTTP request to the provided callback URL (e.g.,
https://vulnerable.app/audio/unique_id) to get the audio. - Twilio calls the user and plays the audio, which contains the 2FA code.
The critical flaw lies in how the vulnerable application constructs the audio_callback_url. Instead of using a fixed, hardcoded domain, the developer used request.host (or similar environment variable) to dynamically build the URL. This is a bad practice because the Host header in an HTTP request can be controlled by the client.
The exploitation steps are:
- An attacker initiates the 2FA process.
- During the request to the vulnerable application, the attacker modifies the
Hostheader toevil.com(a server controlled by the attacker). - The vulnerable application, using
request.host, constructs theaudio_callback_urlashttps://evil.com/audio/unique_idand sends it to Twilio. - Twilio, unaware of the manipulation, makes an HTTP request to
evil.com/audio/unique_id. - The attacker's
evil.comserver receives this request, including theunique_id. - The attacker then uses this
unique_idto make a direct request to the legitimatevulnerable.app/audio/unique_id, retrieves the audio containing the 2FA code, and can then complete the authentication.
The underlying causes are twofold: using request.host for sensitive URL construction and improper web server configuration. Production web servers (like Nginx) should have strict whitelists for Host headers they will process. Similarly, frameworks like Django have an ALLOWED_HOSTS setting that must be correctly configured to prevent the application from responding to arbitrary hostnames.
3. Password Reset Bypass via Null Token
Password reset mechanisms are frequently a source of vulnerabilities due to their sensitive nature. A typical password reset involves:
- User requests a reset, providing their email.
- Application generates a random
password_reset_token, saves it to the user's database record (often in a column defaulted toNULL), and emails a link containing this token. - User clicks the link, providing the token and a new password.
- Application finds the user based on the token, updates the password, clears the
password_reset_token(setting it back toNULL), and logs the user in.
The vulnerability arises when two conditions are met:
- The
password_reset_tokencolumn in the database defaults toNULL(ornilin Ruby, which translates toNULLin databases like MySQL). - The application's "complete password reset" endpoint is susceptible to aggressive input decoding, allowing an attacker to send
token=null(e.g.,{"token": null}in a JSON request).
When the attacker sends token=null, the application's query to find the user becomes WHERE password_reset_token IS NULL. Since all users who don't have an active password reset flow will have a NULL token, this query will return the first user record in the database that matches this condition. The application then resets that user's password (e.g., to "let_me_in") and logs the attacker in as that user.
To compromise multiple accounts, the attacker can:
- Perform the attack, gaining access to a random user.
- Once logged in as that user, initiate a legitimate password reset flow for that specific user. This action will update their
password_reset_tokento a non-NULLvalue. - Repeat the original attack. Since the previously compromised user no longer has a
NULLtoken, the queryWHERE password_reset_token IS NULLwill now return the next user in the database with aNULLtoken. This process can be repeated to systematically compromise all accounts without an active password reset.
The fix is to ensure the password_reset_token column never defaults to NULL. Instead, it should default to an empty string or a non-guessable value, or ideally, the application should strictly validate that a received token is not NULL before performing a lookup.
4. Double Spend via PayPal IPN Handler Misconfiguration
This vulnerability targets common integrations between merchant applications and payment gateways like PayPal, specifically using Instant Payment Notifications (IPN). The standard flow is:
- User clicks "Pay with PayPal" on a merchant site.
- User is redirected to PayPal, completes payment.
- User is redirected back to the merchant's "Thank You" page.
- Concurrently, PayPal sends an asynchronous HTTP POST request (the IPN) to a pre-configured URL on the merchant's server. This IPN contains details about the payment (
grossamount,payment_status,receiver_email,customdata likeuser_ID). - The merchant's IPN handler receives this data. Crucially, a secure handler must send all received IPN data back to PayPal for verification. PayPal responds "VERIFIED" or "INVALID". If verified, the merchant processes the transaction (e.g., credits the user, dispatches goods).
The vulnerability arises when the merchant's IPN handler fails to verify the receiver_email against the merchant's actual PayPal account email.
The double-spend exploitation steps are:
- An attacker creates their own PayPal account and sets up their own IPN listener (e.g., on
evil.com). - The attacker then creates a PayPal payment button on
evil.com, embedding a legitimatecustomparameter (e.g., apurchase_IDoruser_ID) obtained from the vulnerable merchant's site. - The attacker makes a payment to themselves (from their credit card to their own PayPal account) using their button on
evil.com. - PayPal sends the IPN data for this payment to the attacker's
evil.comlistener. This IPN data includes the attacker'sreceiver_emailand the stolencustomID. - The attacker then takes this IPN data and forwards it as an HTTP POST request to the vulnerable merchant's IPN handler.
- The vulnerable merchant's handler receives this data. It sends it back to PayPal for verification. PayPal responds "VERIFIED" because the payment was legitimate (from attacker to attacker).
- Since the merchant's handler does not check the
receiver_email, it processes the transaction, crediting the attacker's account on the merchant site (identified by thecustomID) for a payment that never went to the merchant. The attacker effectively gets goods/services for free.
Riancho contrasts PayPal's API design with Mercado Pago (a payment gateway popular in Latin America). Mercado Pago's IPN system only sends an event_ID to the merchant. The merchant then uses their API key to query Mercado Pago for the full event details. This design inherently prevents the double-spend, as Mercado Pago's API will only return event details if the querying merchant's API key is authorized for that event_ID, preventing an attacker from querying for events belonging to their own account. PayPal's design, by pushing verification responsibility to the merchant, creates this vulnerability.
5. Ruby on Rails ActiveSupport::MessageVerifier RCE
The final vulnerability targets Rails' ActiveSupport::MessageVerifier, a utility for signing messages to ensure their integrity. It takes a message, signs it with a secret key, and produces a string like base64(message)--signature. The message itself is not encrypted, only integrity-protected. A key feature is that it can sign and serialize any Ruby object.
The critical flaw lies in the default serializer used: Ruby's built-in Marshal module. The documentation for Marshal explicitly states that "unmarshaling arbitrary data is insecure and will lead to arbitrary code execution." This is because Marshal can serialize and deserialize complex Ruby objects, including objects that, upon deserialization, trigger method calls that can be exploited for RCE.
The exploitation steps are:
- Secret Key Disclosure: The attacker needs the
secretkey used by the application to sign messages. Riancho mentions finding secrets like "hackme", "i_feel_lonely", or even incremental user IDs in real-world scenarios, making brute-forcing or discovery feasible. - Gadget Creation: The attacker crafts a specially designed Ruby object (a gadget) that, when unmarshaled by the
Marshalmodule, executes arbitrary system commands. - Serialization and Signing: The attacker serializes this gadget using
Marshal, then signs the serialized gadget using the stolen secret key. - Transmission: The attacker sends the crafted
base64(gadget)--signaturestring back to the vulnerable application. - Verification and RCE: The application verifies the signature (which matches because the attacker used the correct secret). Then, it attempts to unmarshal the message using
Marshal.load(), which triggers the gadget and leads to remote code execution.
This vulnerability is similar to known Rails cookie deserialization RCEs that occur if the application's secret_key_base is leaked.
Demo / Proof of Concept
▶ Watch: Remote Code Execution via ActiveSupport MessageVerifier (47:00)
While Andres Riancho did not perform live demonstrations in the traditional sense, his talk was structured as a series of detailed, step-by-step walkthroughs of each vulnerability's exploitation. For each esoteric flaw, he presented:
- Vulnerable Code Snippets: Showing specific lines of Ruby on Rails code (or conceptual logic for other frameworks/integrations) that contained the flaw.
- Attack Request Examples: Illustrating how an attacker would craft malicious HTTP requests (e.g., specific JSON payloads for NoSQL injection, manipulated
Hostheaders for 2FA bypass,token=nullfor password reset, forwarded IPN data for double spend, or base64-encoded signed gadgets for RCE). - Expected Application Behavior: Explaining the application's internal processing of the malicious input and how it deviates from secure behavior.
- Outcome of the Attack: Clearly detailing the impact, such as bypassing authentication, intercepting 2FA codes, resetting arbitrary user passwords, performing fraudulent transactions, or achieving remote code execution.
These detailed explanations served as effective proofs of concept, demonstrating the feasibility and impact of each vulnerability without requiring a live setup. The clarity of the technical deep dives allowed the audience to understand exactly how each attack worked and why it succeeded.
Defensive Implications
▶ Watch: Why security professionals should focus on complex vulnerabilities (49:50)
Andres Riancho provides actionable defensive strategies for each vulnerability, emphasizing a shift from reactive patching to proactive, architectural security:
- Aggressive Input Decoding Leading to NoSQL Injection:
- Strict Input Validation: Developers must assume all user input is malicious and explicitly define the expected type and structure of parameters. Riancho recommends gems like Sinatra Params for Ruby on Rails, which enforce type validation (e.g.,
params[:name]must be a string) and raise exceptions if violated. - Strong Params: Rails' built-in Strong Params mechanism, originally designed for SQL, can be adapted for NoSQL databases to whitelist permitted parameters and prevent mass assignment of sensitive fields or unexpected data structures.
- Explicit Type Casting: As a last resort, always explicitly cast incoming parameters to the expected type (e.g.,
params[:token].to_sor.to_i). However, Riancho notes this is error-prone and easily forgotten.
- 2FA Bypass via Call-back URL Manipulation:
- Fixed Callback URLs: Never construct sensitive callback URLs using user-controlled input like
request.host. Instead, use hardcoded, fully qualified domain names for all API interactions and callbacks. - Web Server Host Whitelisting: Properly configure your web server (e.g., Nginx, Apache) to only respond to requests for explicitly whitelisted domain names. Requests with unknown
Hostheaders should be dropped or redirected. Frameworks like Django also haveALLOWED_HOSTSsettings that must be correctly configured. This prevents the application from processing requests intended for an attacker-controlled domain.
- Password Reset Bypass via Null Token:
- Non-NULL Defaults for Tokens: Ensure that database columns storing sensitive tokens (like
password_reset_token) never default toNULL. Instead, use an empty string, a default random string, or ensure a non-NULL value is always set upon user creation. - Strict Token Validation: The password reset completion endpoint should rigorously validate the received token, ensuring it is a non-empty string of the expected format, and not
NULLor an empty value.
- Double Spend via PayPal IPN Handler Misconfiguration:
- Verify
receiver_email: This is the most critical defense. The merchant's IPN handler must verify that thereceiver_emailparameter in the incoming IPN data matches the merchant's actual PayPal account email address. If they don't match, the payment notification should be rejected as fraudulent. - Secure API Design: When integrating with payment gateways, prefer APIs that push less security responsibility onto the merchant. APIs that provide an event ID, requiring the merchant to query the gateway's API (with an API key) for details (like Mercado Pago), are inherently more secure as the gateway can enforce ownership.
- Ruby on Rails
ActiveSupport::MessageVerifierRCE:
- Strong, Unique Secrets: Use long, cryptographically strong, and unique secret keys for signing messages. These keys should be properly protected and never hardcoded or easily guessable.
- Change Serializer: The default
Marshalserializer is inherently insecure for untrusted data. Explicitly configureActiveSupport::MessageVerifierto use a safer serializer like JSON:ActiveSupport::MessageVerifier.new(secret, serializer: JSON). JSON deserialization does not carry the same RCE risks asMarshalwhen dealing with arbitrary objects.
Across all these defenses, Riancho emphasizes the importance of source code review as the primary method for identifying these subtle vulnerabilities, as automated tools often miss them. He encourages security professionals to understand the underlying logic and design decisions, and to advocate for secure coding practices from an architectural perspective.
Key Takeaways
- Evolving Threat Landscape: Common vulnerabilities like SQL Injection and XSS are becoming less prevalent due to modern frameworks, requiring security professionals to focus on more complex, "esoteric" flaws.
- Human Intellect over Automation: Automated tools are good for "boring" vulnerabilities, but human expertise, particularly through source code review, is essential for discovering subtle, application-specific issues.
- Aggressive Input Decoding Risks: Frameworks' flexible input parsing can turn simple strings into complex objects (e.g., hashes), which can be exploited for NoSQL injection or other logic flaws if not strictly validated.
- Host Header Dangers: Dynamically generating sensitive URLs (e.g., API callbacks) based on the HTTP
Hostheader is dangerous and can lead to SSRF or data interception, especially if web servers are misconfigured. - Payment Gateway Integration Pitfalls: Relying solely on payment gateway notifications (like PayPal IPN) without thorough server-side validation (e.g., verifying
receiver_email) can lead to financial fraud and double-spend attacks. - Insecure Deserialization: Default serialization mechanisms (like Ruby's
Marshalmodule) can be highly insecure if used with untrusted input, leading to Remote Code Execution (RCE) if the application's secret key is compromised. Always prefer secure serializers like JSON.
About the Speaker(s)
Andres Riancho is a seasoned security professional with over ten years of experience in source code reviews and application penetration testing. A passionate developer who codes primarily in Python, Riancho is widely recognized as the creator of the w3af project, an open-source web application security scanner. His work focuses on identifying complex vulnerabilities and pushing the boundaries of what security tools can achieve, while also advocating for the indispensable role of human analysis in uncovering sophisticated application flaws. His expertise spans across various web technologies and frameworks, making him a knowledgeable voice in the realm of web application security.