Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sqlite vulnerable to code execution due to Object coercion #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

imhunterand
Copy link

Overview
Affected versions of this project SiliconLabs/zap are vulnerable to Arbitrary Code Execution via the .ToString() method due to improper sanitization. Exploiting this vulnerability is possible when a binding parameter is a crafted Object and might result in arbitrary JavaScript code execution or DoS. Ensure sufficient sanitization in the parent application to protect against invalid values being supplied to binding parameters.

    }
    else if (source.IsObject()) {
        Napi::String napiVal = source.ToString();
        // Check whether toString returned a value that is not undefined.
        if(napiVal.Type() == 0) {
            return NULL;
   it('should ignore faulty toString in array', function(done) {
       const faulty = [[{toString: null}], 1];
       db.all('SELECT * FROM txt_table WHERE txt = ? LIMIT ?', faulty, function (err) {
           assert.equal(err, null);
           done();
       });
   });

   it('should ignore faulty toString set to function', function(done) {
       const faulty = [[{toString: function () {console.log('oh no');}}], 1];
       db.all('SELECT * FROM txt_table WHERE txt = ? LIMIT ?', faulty, function (err) {
           assert.equal(err, undefined);
           done();
       });
   });

**Overview**
Affected versions of this project `SiliconLabs/zap` are vulnerable to Arbitrary Code Execution via the .ToString() method due to improper sanitization. Exploiting this vulnerability is possible when a binding parameter is a crafted Object and might result in arbitrary JavaScript code execution or DoS. Ensure sufficient sanitization in the parent application to protect against invalid values being supplied to binding parameters.


```
    }
    else if (source.IsObject()) {
        Napi::String napiVal = source.ToString();
        // Check whether toString returned a value that is not undefined.
        if(napiVal.Type() == 0) {
            return NULL;
```
 ```js
    it('should ignore faulty toString in array', function(done) {
        const faulty = [[{toString: null}], 1];
        db.all('SELECT * FROM txt_table WHERE txt = ? LIMIT ?', faulty, function (err) {
            assert.equal(err, null);
            done();
        });
    });

    it('should ignore faulty toString set to function', function(done) {
        const faulty = [[{toString: function () {console.log('oh no');}}], 1];
        db.all('SELECT * FROM txt_table WHERE txt = ? LIMIT ?', faulty, function (err) {
            assert.equal(err, undefined);
            done();
        });
    });
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant