Repository navigation
Making proper use of strictOrigins #1118
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
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
9876274
Add proper-lockfile dependency.
RubenVerborgh 74e5464
Lock file during patching.
RubenVerborgh a4aeb9e
Making proper use of strictOrigins
megoth c8a23a9
Fixed some faulty tests
megoth 01853af
Added RubenVerborgh explanation
megoth f5d2816
Revert "Lock file during patching."
megoth 017ca05
Did a faulty rebase, trying to revert commits
megoth 7c0d436
Revert "Add proper-lockfile dependency."
megoth 06c5b19
Trying to make tests less dependent on order
megoth 1998a5b
Removing the need to run tests in order
megoth 0ece321
Some optimizations
megoth b486abe
Trying to revert authentication-oidc-test manually
megoth de3b0e0
Fixing alignment
megoth 4fd4f90
Revert "Trying to make tests less dependent on order"
megoth 7b75a0b
Making changes minimal for acl-tls-test.js
megoth e4cf1e2
Reverting changes to solid-host
megoth File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -178,6 +178,39 @@ describe('Authentication API (OIDC)', () => { | |
| }) | ||
| }) | ||
|
|
||
| describe('with that cookie and a non-matching origin', () => { | ||
| let response | ||
| before(done => { | ||
| alice.get('/private-for-alice.txt') | ||
| .set('Cookie', cookie) | ||
| .set('Origin', bobServerUri) | ||
| .end((err, res) => { | ||
| response = res | ||
| done(err) | ||
| }) | ||
| }) | ||
|
|
||
| it('should return a 403', () => { | ||
| expect(response).to.have.property('status', 403) | ||
| }) | ||
| }) | ||
|
|
||
| describe('without that cookie and a non-matching origin', () => { | ||
| let response | ||
| before(done => { | ||
| alice.get('/private-for-alice.txt') | ||
| .set('Origin', bobServerUri) | ||
| .end((err, res) => { | ||
| response = res | ||
| done(err) | ||
| }) | ||
| }) | ||
|
|
||
| it('should return a 401', () => { | ||
| expect(response).to.have.property('status', 401) | ||
| }) | ||
| }) | ||
|
|
||
| describe('with that cookie but without origin', () => { | ||
| let response | ||
| before(done => { | ||
|
|
@@ -194,6 +227,19 @@ describe('Authentication API (OIDC)', () => { | |
| }) | ||
| }) | ||
|
|
||
| describe('with that cookie, private resource and no origin set', () => { | ||
| before(done => { | ||
| alice.get('/private-for-alice.txt') | ||
| .set('Cookie', cookie) | ||
| .end((err, res) => { | ||
| response = res | ||
| done(err) | ||
| }) | ||
| }) | ||
|
|
||
| it('should return a 200', () => expect(response).to.have.property('status', 200)) | ||
| }) | ||
|
|
||
| // How Mallory might set their cookie: | ||
| describe('with malicious cookie but without origin', () => { | ||
| let response | ||
|
|
@@ -295,8 +341,8 @@ describe('Authentication API (OIDC)', () => { | |
| }) | ||
| }) | ||
|
|
||
| it('should return a 403', () => { | ||
| expect(response).to.have.property('status', 403) // TODO: Should be 401? | ||
| it('should return a 401', () => { | ||
| expect(response).to.have.property('status', 401) | ||
| }) | ||
| }) | ||
|
|
||
|
|
@@ -314,8 +360,8 @@ describe('Authentication API (OIDC)', () => { | |
| }) | ||
| }) | ||
|
|
||
| it('should return a 403', () => { | ||
| expect(response).to.have.property('status', 403) | ||
| it('should return a 401', () => { | ||
| expect(response).to.have.property('status', 401) | ||
| }) | ||
| }) | ||
|
|
||
|
|
@@ -332,8 +378,8 @@ describe('Authentication API (OIDC)', () => { | |
| }) | ||
| }) | ||
|
|
||
| it('should return a 403', () => { | ||
| expect(response).to.have.property('status', 403) | ||
| it('should return a 401', () => { | ||
| expect(response).to.have.property('status', 401) | ||
| }) | ||
| }) | ||
|
|
||
|
|
@@ -355,7 +401,24 @@ describe('Authentication API (OIDC)', () => { | |
| }) | ||
| }) | ||
|
|
||
| // Authenticated but origin not OK | ||
| describe('with malicious cookie and our origin', () => { | ||
| let response | ||
| before(done => { | ||
| var malcookie = cookie.replace(/connect\.sid=(\S+)/, 'connect.sid=l33th4x0rzp0wn4g3;') | ||
| alice.get('/private-for-alice.txt') | ||
| .set('Cookie', malcookie) | ||
| .set('Origin', aliceServerUri) | ||
| .end((err, res) => { | ||
| response = res | ||
| done(err) | ||
| }) | ||
| }) | ||
|
|
||
| it('should return a 401', () => { | ||
| expect(response).to.have.property('status', 401) | ||
| }) | ||
| }) | ||
|
|
||
| describe('with malicious cookie and a non-matching origin', () => { | ||
| let response | ||
| before(done => { | ||
|
|
@@ -369,8 +432,8 @@ describe('Authentication API (OIDC)', () => { | |
| }) | ||
| }) | ||
|
|
||
| it('should return a 403', () => { | ||
| expect(response).to.have.property('status', 403) | ||
| it('should return a 401', () => { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again here I would prefer a 403, since it is good to fend off an attacker at once, but it is even less important than the previous comment, since it is most important to just deny them. |
||
| expect(response).to.have.property('status', 401) | ||
| }) | ||
| }) | ||
| }) | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not terribly important, but as per the comment above the test, I still think 403 is the correct status. How hard would it be to fix?