question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Security: 'unterminated quoted string' updating model

See original GitHub issue

We have a case from fuzzy scanning that results in the following error:

unterminated quoted string at or near "'"
LINE 1: UPDATE "production"."questions" SET "text"='

The error is caused by a model instance being updated, like this:

const question = await sequelize.models.Entity.findById(questionId);
await question.update({
  text: req.body.text
});

The req.body.text is validated to be a string and within the right length. We suspect this is caused by some special character being inside req.body.text, that fools the escaping logic in Sequelize. If https://github.com/sequelize/sequelize/issues/1608 is implemented, this would be a non-issue, as you will skip any messy escaping, that is extremely hard to do properly, just ask the PHP guys.

Most likely this makes Sequelize vulnerable to SQL injection for any uses that accept text from the user (which I would guess is pretty close to all uses of Sequelize).

Dialect: postgres Database version: 9.5 Sequelize version: 3.23.4

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
mickhansencommented, Jul 20, 2016

@holm In any case we’d probably want to throw explicitly, escape or filter when facing a value that postgres doesn’t accept.

0reactions
holmcommented, Jul 20, 2016

Understanding the problem better, I don’t think this can actually be used for any injection, since the null character seems to terminate the current statement. However I have seen people be very clever with these injections before, so hard to be sure.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to fix this Error on starting Splunk on UBUNTU...
splunk: 1: Syntax error: Unterminated quoted string root@ubuntu-linux-22-04-desktop:/opt/splunk/bin#. Error on starting Splunk on UBUNTU ...
Read more >
bash: can't find unterminated quote string location, what is the ...
I have made a script to run a backup from a local machine to a remote server. However when running this script I...
Read more >
Solved: Post-Build Failure, Unterminated Quoted String
Solved: Although the code compiles and works properly, I get a post-build syntax error that has me worried. Here is what I see:...
Read more >
Syntax error: Unterminated quoted string - Unix Stack Exchange
Your error message clearly says that there is an unterminated quoted string in /etc/environment . Once you read that, you should investigate ...
Read more >
syntax error: unterminated quoted string literal
syntax error: unterminated quoted string literal · 1. You will see this error when data file name is wrong in the control file...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found