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

test file (information leak) #137 #139

Merged
merged 3 commits into from
Feb 21, 2022
Merged

test file (information leak) #137 #139

merged 3 commits into from
Feb 21, 2022

Conversation

Sampaguitas
Copy link
Contributor

Test file for cookie header being leaked to third party website in Open Redirects.

'authorization': 'Bearer eyJhb12345abcdef'
}
}, function (err, response, body) {
t.strictEqual(Object.keys(body).length, 0);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this only tests that the request response is empty, not that a redirect occurred and google.com received the authorization header.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see my comment #138 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is the test file with open redirect:

'use strict';

var request = require('../').defaults({ json: true });;
var t = require('chai').assert;

describe('Information Leak', function () {

    it('should not forward cookie headers when the request has a redirect', function (done) {

        request({
            url: 'https://httpbingo.org/redirect-to?url=http://httpbingo.org/cookies',
            headers: {
                'Content-Type': 'application/json',
                'cookie': 'ajs_anonymous_id=1234567890',
                'authorization': 'Bearer eyJhb12345abcdef'
            }
        }, function (err, response, body) {
            t.strictEqual(Object.keys(body).length, 0);
            done();
        });
    });

    it('should not forward authorization headers when the request has a redirect', function (done) {

        request({
            url: 'https://httpbingo.org/redirect-to?url=http://httpbingo.org/bearer',
            headers: {
                'Content-Type': 'application/json',
                'cookie': 'ajs_anonymous_id=1234567890',
                'authorization': 'Bearer eyJhb12345abcdef'
            }
        }, function (err, response, body) {
            t.strictEqual(body, undefined);
            done();
        });
    });

});

Without the patch /redirect-to pass the cookie to /cookies who sends it back in the body of the response.

The protocol of /cookie is different from /redirect-to so the cookie should have been removed from the header before making the request.

If the response body is an empty object "Object.keys(body).length === 0", it means that the function as successfully removed the cookie from the header before making the request so the test succeeded.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now I can confirm that the test works with that code :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merci d'avoir pris le temps daccepter mon pull request🙂🥳

@FGRibreau FGRibreau merged commit f517344 into FGRibreau:master Feb 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants