-
Notifications
You must be signed in to change notification settings - Fork 254
CLDSRV-849: don't crash if invalid Date header #6079
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
bert-e
merged 3 commits into
development/9.2
from
bugfix/CLDSRV-849-dont-crash-if-invalid-Date-header
Feb 16, 2026
+85
−5
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| const assert = require('assert'); | ||
| const http = require('http'); | ||
|
|
||
| const bucket = 'test-bucket'; | ||
| const objectKey = 'test-file.txt'; | ||
|
|
||
| describe('malformed Date header:', () => { | ||
| it('should return AccessDenied for bad date with x-amz-content-sha256 header', done => { | ||
| const options = { | ||
| hostname: 'localhost', | ||
| port: 8000, | ||
| path: `/${bucket}/${objectKey}`, | ||
| method: 'GET', | ||
| headers: { | ||
| 'Date': 'BAD_DATE', | ||
| 'Authorization': 'AWS4-HMAC-SHA256 Credential=accessKey1/20260211/us-east-1/s3/aws4_request, ' + | ||
| 'SignedHeaders=host, Signature=d459d5b2a2395b4c65d8f8aa2729b22c5abb04614fafbd93ab4fe203e76d21a3', | ||
| 'X-Amz-Content-Sha256': 'fa8d015f89da2a769d1cea7e3bd77a5670d098d7844cda148a40c1304e5b778b', | ||
| 'Host': 'localhost:8000' | ||
| } | ||
| }; | ||
|
|
||
| const req = http.request(options, res => { | ||
| let body = ''; | ||
| res.on('data', chunk => { | ||
| body += chunk; | ||
| }); | ||
| res.on('end', () => { | ||
| assert.strictEqual(res.statusCode, 403, 'Server should return 403 AccessDenied for malformed Date'); | ||
| assert(body.includes('AccessDenied'), 'Response should contain AccessDenied'); | ||
| assert(body.includes('Authentication requires a valid Date or x-amz-date header')); | ||
| done(); | ||
| }); | ||
| }); | ||
|
|
||
| req.on('error', err => { | ||
| // If we get ECONNRESET or similar, it means the server crashed | ||
| assert.fail(`Server crashed or connection error: ${err.message}`); | ||
| }); | ||
|
|
||
| req.end(); | ||
| }); | ||
|
|
||
| it('should return AccessDenied for bad x-amz-date with x-amz-content-sha256 header', done => { | ||
| const options = { | ||
| hostname: 'localhost', | ||
| port: 8000, | ||
| path: `/${bucket}/${objectKey}`, | ||
| method: 'GET', | ||
| headers: { | ||
| 'X-Amz-Date': 'BAD_DATE', | ||
| 'Authorization': 'AWS4-HMAC-SHA256 Credential=accessKey1/20260211/us-east-1/s3/aws4_request, ' + | ||
| 'SignedHeaders=host;x-amz-date, ' + | ||
| 'Signature=d459d5b2a2395b4c65d8f8aa2729b22c5abb04614fafbd93ab4fe203e76d21a3', | ||
| 'X-Amz-Content-Sha256': 'fa8d015f89da2a769d1cea7e3bd77a5670d098d7844cda148a40c1304e5b778b', | ||
| 'Host': 'localhost:8000' | ||
| } | ||
| }; | ||
|
|
||
| const req = http.request(options, res => { | ||
BourgoisMickael marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| let body = ''; | ||
| res.on('data', chunk => { | ||
| body += chunk; | ||
| }); | ||
| res.on('end', () => { | ||
| assert.strictEqual(res.statusCode, 403, 'Server should return 403 AccessDenied for malformed Date'); | ||
| assert(body.includes('AccessDenied'), 'Response should contain AccessDenied'); | ||
| assert(body.includes('Authentication requires a valid Date or x-amz-date header')); | ||
| done(); | ||
| }); | ||
| }); | ||
|
|
||
| req.on('error', err => { | ||
| // If we get ECONNRESET or similar, it means the server crashed | ||
| assert.fail(`Server crashed or connection error: ${err.message}`); | ||
| }); | ||
|
|
||
| req.end(); | ||
| }); | ||
| }); | ||
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
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.
With the fixed date in the authorization is it going to work any other day ?
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.
We test the Date, before the
Authorizationso it does not matterThere 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.
We also check the error string
Authentication requires a valid Date or x-amz-date header, so it we fail for another reason we would find outThere 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.
You can put that comment direct into code so we know when we read it next time