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

v1.2.28 #1052

Merged
merged 54 commits into from
Jan 9, 2024
Merged

v1.2.28 #1052

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
a734799
Update deps
lestrrat Jun 13, 2022
01a9ce9
remove stray v2 import
lestrrat Jun 15, 2022
510b449
Bump github.com/stretchr/testify from 1.7.2 to 1.7.5
dependabot[bot] Jun 24, 2022
378663f
run make tidy
lestrrat Jun 24, 2022
cbed577
Bump github.com/goccy/go-json from 0.9.7 to 0.9.8 (#769)
lestrrat Jul 1, 2022
2f167a1
Bump github.com/stretchr/testify from 1.7.5 to 1.8.0 (#771)
lestrrat Jul 2, 2022
57b203d
bump github/goccy/go-json to 0.9.10 (#780)
lestrrat Jul 19, 2022
f0baa05
Update deps (#800)
lestrrat Aug 19, 2022
c73cbae
Update develop/v1 to testify v1.8.1
lestrrat Oct 27, 2022
1753b7c
Bump github.com/goccy/go-json from 0.9.11 to 0.10.0 (#856)
dependabot[bot] Nov 30, 2022
9d988d3
Update develop/v1 CI (#862)
lestrrat Jan 15, 2023
973b031
Bump github.com/lestrrat-go/option from 1.0.0 to 1.0.1 (#861)
lestrrat Jan 15, 2023
12eb57c
Update Changes
lestrrat Jan 15, 2023
cb52f3a
Bump golang.org/x/crypto from 0.0.0-20220427172511-eb4f295cb31f to 0.…
dependabot[bot] Mar 1, 2023
177869c
Bump github.com/stretchr/testify from 1.8.1 to 1.8.2 (#874)
dependabot[bot] Mar 1, 2023
c934b8f
Bump golang.org/x/crypto from 0.6.0 to 0.7.0
dependabot[bot] Mar 6, 2023
a71ce91
Run make tidy
lestrrat Mar 6, 2023
6e3a599
Bump github.com/goccy/go-json from 0.10.0 to 0.10.1 (#883)
dependabot[bot] Mar 15, 2023
cae7d4e
Bump github.com/goccy/go-json from 0.10.1 to 0.10.2 (#891)
dependabot[bot] Mar 21, 2023
16ae225
Bump golang.org/x/crypto from 0.7.0 to 0.8.0 (#898)
dependabot[bot] Apr 12, 2023
9cc1c2d
Bump actions/checkout from 2 to 3 (#900)
dependabot[bot] Apr 12, 2023
f325fbe
Bump kentaro-m/auto-assign-action from 1.2.0 to 1.2.5 (#901)
dependabot[bot] Apr 12, 2023
f949e51
Bump actions/cache from 2 to 3 (#902)
dependabot[bot] Apr 12, 2023
25e0dcd
Bump actions/setup-go from 2 to 4 (#903)
dependabot[bot] Apr 12, 2023
ba4b3e9
Bump actions/stale from 7 to 8 (#904)
dependabot[bot] Apr 12, 2023
f49bf34
Bump github.com/decred/dcrd/dcrec/secp256k1/v4 from 4.1.0 to 4.2.0 (#…
dependabot[bot] Apr 19, 2023
b4a2301
Bump golang.org/x/crypto from 0.8.0 to 0.9.0 (#920)
dependabot[bot] May 9, 2023
fda89f1
Bump github.com/stretchr/testify from 1.8.2 to 1.8.3 (#926)
dependabot[bot] May 23, 2023
85ba586
Bump github.com/stretchr/testify from 1.8.3 to 1.8.4 (#930)
dependabot[bot] Jun 10, 2023
4e92eb3
port extract padding fix from https://github.com/lestrrat-go/jwx/comm…
lestrrat Jun 14, 2023
9f1f893
Update Changes
lestrrat Jun 14, 2023
28b4a6a
Bump golang.org/x/crypto from 0.9.0 to 0.10.0 (#937)
dependabot[bot] Jun 20, 2023
15937e4
Accept a single KeyOperation in key.Set() (#946)
lestrrat Jun 21, 2023
51142ca
Bump golang.org/x/crypto from 0.10.0 to 0.11.0 (#955)
dependabot[bot] Jul 7, 2023
55c7a16
Bump golang.org/x/crypto from 0.11.0 to 0.12.0 (#962)
dependabot[bot] Aug 8, 2023
6e8947f
Bump actions/checkout from 3 to 4 (#973)
dependabot[bot] Sep 7, 2023
22aecfb
Bump golang.org/x/crypto from 0.12.0 to 0.13.0 (#975)
dependabot[bot] Sep 25, 2023
4a15873
Update golangci-lint to 1.54.2 (#988)
lestrrat Sep 26, 2023
915fbc1
Bump github.com/lestrrat-go/blackmagic from 1.0.1 to 1.0.2 (#984)
dependabot[bot] Sep 26, 2023
bee5726
Bump golang.org/x/crypto from 0.13.0 to 0.14.0 (#992)
dependabot[bot] Oct 16, 2023
5264107
Bump golang.org/x/crypto from 0.14.0 to 0.15.0
dependabot[bot] Nov 9, 2023
8d0d7c7
Run make tidy
lestrrat Nov 12, 2023
9e4f840
Bump golang.org/x/crypto from 0.15.0 to 0.16.0 (#1021)
dependabot[bot] Dec 1, 2023
023b88f
Fix p2c (#1025)
lestrrat Dec 3, 2023
dadedec
Update Changes
lestrrat Dec 3, 2023
eec09b5
Merge branch 'v1' into develop/v1
lestrrat Dec 3, 2023
795d086
Bump actions/setup-go from 4 to 5 (#1028)
dependabot[bot] Dec 7, 2023
6ce07b5
Bump actions/stale from 8 to 9 (#1030)
dependabot[bot] Dec 10, 2023
bc10917
Bump golang.org/x/crypto from 0.16.0 to 0.17.0
dependabot[bot] Dec 19, 2023
ec45859
Run make tidy
lestrrat Dec 19, 2023
ada60c8
Merge pull request from GHSA-pvcr-v8j8-j5q3
lestrrat Jan 9, 2024
b16a942
Merge remote-tracking branch 'origin/v1' into develop/v1
lestrrat Jan 9, 2024
895de44
Update Changes
lestrrat Jan 9, 2024
e25f843
Fix typo
lestrrat Jan 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
restore-keys: |
${{ runner.os }}-go-
- name: Install Go stable version
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}
- name: Install benchstat
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
run: curl --connect-timeout 1 https://azure.archive.ubuntu.com || (sudo sed -i 's/azure\.//' /etc/apt/sources.list && sudo apt-get update)
- name: Install Go stable version
if: matrix.go != 'tip'
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}
- name: Install Go tip
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
- uses: actions/setup-go@v5
with:
go-version: 1.19
check-latest: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/smoke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
- name: Munge APT Repositories
run: curl --connect-timeout 1 https://azure.archive.ubuntu.com || (sudo sed -i 's/azure\.//' /etc/apt/sources.list && sudo apt-get update)
- name: Install Go stable version
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}
- name: Install stringer
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v8
- uses: actions/stale@v9
with:
stale-issue-message: 'This issue is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 7 days.'
stale-pr-message: 'This PR is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 14 days.'
Expand Down
13 changes: 12 additions & 1 deletion Changes
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
Changes
=======

v1.2.28 09 Jan 2024
[Security Fixes]
* [jws] JWS messages formated in full JSON format (i.e. not the compact format, which
consists of three base64 strings concatenated with a '.') with missing "protected"
headers could cause a panic, thereby introducing a possiblity of a DoS.

This has been fixed so that the `jws.Parse` function succeeds in parsing a JWS message
lacking a protected header. Calling `jws.Verify` on this same JWS message will result
in a failed verification attempt. Note that this behavior will differ slightly when
parsing JWS messages in compact form, which result in an error.

v1.2.27 - 03 Dec 2023
[Security]
* [jwe] A large number in p2c parameter for PBKDF2 based encryptions could cause a DoS attack,
Expand Down Expand Up @@ -247,7 +258,7 @@ v1.2.6 24 Aug 2021
* Support `crypto.Signer` keys for RSA, ECDSA, and EdDSA family
of signatures in `jws.Sign`
[Miscellaneous]
* `jwx.GuessFormat()` now requires the presense of both `payload` and
* `jwx.GuessFormat()` now requires the presence of both `payload` and
`signatures` keys for it to guess that a JSON object is a JWS message.
* Slightly enhance `jwt.Parse()` performance.

Expand Down
4 changes: 2 additions & 2 deletions bench/performance/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXl
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY=
golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k=
golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
Expand Down
4 changes: 2 additions & 2 deletions examples/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXl
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY=
golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k=
golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
github.com/lestrrat-go/option v1.0.1
github.com/pkg/errors v0.9.1
github.com/stretchr/testify v1.8.4
golang.org/x/crypto v0.16.0
golang.org/x/crypto v0.17.0
)

retract v1.2.16 // Packaging problems.
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXl
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY=
golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k=
golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
Expand Down
53 changes: 53 additions & 0 deletions jws/jws_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"github.com/lestrrat-go/jwx/jwk"
"github.com/lestrrat-go/jwx/jws"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

const examplePayload = `{"iss":"joe",` + "\r\n" + ` "exp":1300819380,` + "\r\n" + ` "http://example.com/is_root":true}`
Expand Down Expand Up @@ -1795,3 +1796,55 @@ func TestGH681(t *testing.T) {
return
}
}

func TestEmptyProtectedField(t *testing.T) {
// MEMO: this was the only test case from the original report
// This passes. It should produce an invalid JWS message, but
// that's not `jws.Parse`'s problem.
_, err := jws.Parse([]byte(`{"signature": ""}`))
require.NoError(t, err, `jws.Parse should fail`)

// Also test that non-flattened serialization passes.
_, err = jws.Parse([]byte(`{"signatures": [{}]}`))
require.NoError(t, err, `jws.Parse should fail`)

// MEMO: rest of the cases are present to be extra pedantic about it

privKey, err := jwxtest.GenerateRsaJwk()
require.NoError(t, err, `jwxtest.GenerateRsaJwk should succeed`)

// This fails. `jws.Parse` works, but the subsequent verification
// workflow fails to verify anything without the presence of a signature or
// a protected header.
_, err = jws.Verify([]byte(`{"signature": ""}`), jwa.RS256, privKey)
require.Error(t, err, `jws.Parse should fail`)

// Create a valid signatre.
signed, err := jws.Sign([]byte("Lorem Ipsum"), jwa.RS256, privKey)
require.NoError(t, err, `jws.Sign should succeed`)

_, payload, signature, err := jws.SplitCompact(signed)
require.NoError(t, err, `jws.SplitCompact should succeed`)

// This fails as well. we have a valid signature and a valid
// key to verify it, but no protected headers
_, err = jws.Verify(
[]byte(fmt.Sprintf(`{"signature": "%s"}`, signature)),
jwa.RS256, privKey,
)
require.Error(t, err, `jws.Verify should fail`)

// Test for cases when we have an incomplete compact form JWS
var buf bytes.Buffer
buf.WriteRune('.')
buf.Write(payload)
buf.WriteRune('.')
buf.Write(signature)
invalidMessage := buf.Bytes()

// This is an error because the format is simply wrong.
// Whereas in the other JSON-based JWS's case the lack of protected field
// is not a SYNTAX error, this one is, and therefore we barf.
_, err = jws.Parse(invalidMessage)
require.Error(t, err, `jws.Parse should fail`)
}
20 changes: 16 additions & 4 deletions jws/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,13 @@ func (s *Signature) UnmarshalJSON(data []byte) error {
s.protected = prt
}

decoded, err := base64.DecodeString(*sup.Signature)
if err != nil {
return errors.Wrap(err, `failed to base decode signature`)
if sup.Signature != nil {
decoded, err := base64.DecodeString(*sup.Signature)
if err != nil {
return errors.Wrap(err, `failed to base decode signature`)
}
s.signature = decoded
}
s.signature = decoded
return nil
}

Expand Down Expand Up @@ -282,6 +284,11 @@ func (m *Message) UnmarshalJSON(buf []byte) error {
}
sig.SetDecodeCtx(nil)

if sig.protected == nil {
// Instead of barfing on a nil protected header, use an empty header
sig.protected = NewHeaders()
}

if i == 0 {
if !getB64Value(sig.protected) {
b64 = false
Expand Down Expand Up @@ -317,6 +324,11 @@ func (m *Message) UnmarshalJSON(buf []byte) error {
sig.protected = prt
}

if sig.protected == nil {
// Instead of barfing on a nil protected header, use an empty header
sig.protected = NewHeaders()
}

decoded, err := base64.DecodeString(*mup.Signature)
if err != nil {
return errors.Wrap(err, `failed to base64 decode flattened signature`)
Expand Down