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

[THREESCALE-11435] Check for nil value when decode based64 value #1506

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

- Fixed CVE-2023-44487 (HTTP/2 Rapid Reset) [PR #1417](https://github.com/3scale/apicast/pull/1417) [THREESCALE-10224](https://issues.redhat.com/browse/THREESCALE-10224)

- Fixed APIcast panic when parsing invalid base64 encoded value [PR #1505](https://github.com/3scale/APIcast/pull/1505) [THEESCALE-11435](https://issues.redhat.com/browse/THREESCALE-11435)

### Added

- Detect number of CPU shares when running on Cgroups V2 [PR #1410](https://github.com/3scale/apicast/pull/1410) [THREESCALE-10167](https://issues.redhat.com/browse/THREESCALE-10167)
Expand Down
5 changes: 4 additions & 1 deletion gateway/src/resty/http_authorization.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ local _M = {
local mt = { __index = _M }

function _M.parsers.Basic(param)
local userid, password
local user_pass = ngx.decode_base64(param)
local userid, password = match(user_pass, '^(.*):(.*)$')
if user_pass then
userid, password = match(user_pass, '^(.*):(.*)$')
end

return {
userid = userid,
Expand Down
7 changes: 7 additions & 0 deletions spec/resty/http_authorization_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ describe('HTTP Authorization', function()
assert.equal('', auth.userid)
assert.equal('pass', auth.password)
end)

it('do not panic with invalid header', function()
local auth = authorization.new('Basic !123!')

assert.equal(nil, auth.userid)
assert.equal(nil, auth.password)
end)
end)

describe('Bearer', function()
Expand Down
Loading
Loading