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

Token limit fix CVE-2023-49559 #291

Merged
merged 7 commits into from
Jun 11, 2024

Conversation

uvzz
Copy link
Contributor

@uvzz uvzz commented Jan 11, 2024

Hi,

I added a default token limit value of 15000 and a token count inside next() function in parser.go

the limit should be configured by callers of the parser (i.e. gqlgen, genqlient, etc.). - Can you assist with that?

@uvzz uvzz changed the title Token limit fix CVE 2023 49559 Token limit fix CVE-2023-49559 Jan 11, 2024
@coveralls
Copy link

coveralls commented Jan 11, 2024

Coverage Status

coverage: 88.477% (-0.1%) from 88.575%
when pulling d6689ad on uvzz:token-limit-fix-CVE-2023-49559
into 591c98b on vektah:master.

@benjaminjkraft
Copy link
Contributor

This doesn't seem to let callers set the token limit? All the structs in question are private. We will need to figure out how to wire it in, which is a bit painful since there is no existing options API.

One kind of strange way is to make it a field of Source. It's a bit weird at first blush but it actually kinda makes sense that the parsing limit might vary from source to source. That wouldn't make it easy to set a default, and doesn't work for the main LoadQuery API -- but that one could have a default and callers who care could use ParseQuery + Validate, I think?

BTW, my opinion is still that this should be off by default; it is not a vulnerability for a parser to parse what you give it in its entirety, only for an HTTP server to parse input from the network with no limitations. (And I'm still unconvinced that request body size is not a sufficient limitation!) But I understand others might feel differently, so as long as it's possible to disable I'm fine being outvoted on that one.

parser/parser.go Outdated Show resolved Hide resolved
parser/parser.go Outdated Show resolved Hide resolved
parser/query.go Outdated Show resolved Hide resolved
Signed-off-by: Steve Coffman <[email protected]>
@StevenACoffman StevenACoffman merged commit d457fc0 into vektah:master Jun 11, 2024
2 checks passed
@@ -20,7 +20,8 @@ func ParseSchemas(inputs ...*Source) (*SchemaDocument, error) {

func ParseSchema(source *Source) (*SchemaDocument, error) {
p := parser{
lexer: lexer.New(source),
lexer: lexer.New(source),
maxTokenLimit: 15000, // default value
Copy link
Contributor

Choose a reason for hiding this comment

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

this should be 0 too I think? especially since parsing a schema is usually if anything the safer operation

github-merge-queue bot referenced this pull request in infratographer/x Aug 8, 2024
…ecurity] (#238)

[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
|
[github.com/vektah/gqlparser/v2](https://togithub.com/vektah/gqlparser)
| `v2.5.11` -> `v2.5.14` |
[![age](https://developer.mend.io/api/mc/badges/age/go/github.com%2fvektah%2fgqlparser%2fv2/v2.5.14?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/go/github.com%2fvektah%2fgqlparser%2fv2/v2.5.14?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/go/github.com%2fvektah%2fgqlparser%2fv2/v2.5.11/v2.5.14?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/go/github.com%2fvektah%2fgqlparser%2fv2/v2.5.11/v2.5.14?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

### GitHub Vulnerability Alerts

#### [CVE-2023-49559](https://nvd.nist.gov/vuln/detail/CVE-2023-49559)

An issue in vektah gqlparser open-source-library v.2.5.10 allows a
remote attacker to cause a denial of service via a crafted script to the
parserDirectives function.

---

### Release Notes

<details>
<summary>vektah/gqlparser (github.com/vektah/gqlparser/v2)</summary>

###
[`v2.5.14`](https://togithub.com/vektah/gqlparser/releases/tag/v2.5.14)

[Compare
Source](https://togithub.com/vektah/gqlparser/compare/v2.5.13...v2.5.14)

#### What's Changed

- Add ParseQueryWithLimit by
[@&#8203;StevenACoffman](https://togithub.com/StevenACoffman) in
[https://github.com/vektah/gqlparser/pull/304](https://togithub.com/vektah/gqlparser/pull/304)

**Full Changelog**:
vektah/gqlparser@v2.5.13...v2.5.14

###
[`v2.5.13`](https://togithub.com/vektah/gqlparser/releases/tag/v2.5.13)

[Compare
Source](https://togithub.com/vektah/gqlparser/compare/v2.5.12...v2.5.13)

#### What's Changed

- Bump the actions-deps group in /validator/imported with 6 updates by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[https://github.com/vektah/gqlparser/pull/298](https://togithub.com/vektah/gqlparser/pull/298)
- Bump prettier from 3.2.5 to 3.3.0 in /validator/imported in the
actions-deps group by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[https://github.com/vektah/gqlparser/pull/299](https://togithub.com/vektah/gqlparser/pull/299)
- Bump the actions-deps group in /validator/imported with 7 updates by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[https://github.com/vektah/gqlparser/pull/301](https://togithub.com/vektah/gqlparser/pull/301)
- Bump braces from 3.0.2 to 3.0.3 in /validator/imported by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[https://github.com/vektah/gqlparser/pull/302](https://togithub.com/vektah/gqlparser/pull/302)
- Token limit fix CVE-2023-49559 by
[@&#8203;uvzz](https://togithub.com/uvzz) in
[https://github.com/vektah/gqlparser/pull/291](https://togithub.com/vektah/gqlparser/pull/291)

#### New Contributors

- [@&#8203;uvzz](https://togithub.com/uvzz) made their first
contribution in
[https://github.com/vektah/gqlparser/pull/291](https://togithub.com/vektah/gqlparser/pull/291)

**Full Changelog**:
vektah/gqlparser@v2.5.12...v2.5.13

###
[`v2.5.12`](https://togithub.com/vektah/gqlparser/releases/tag/v2.5.12)

[Compare
Source](https://togithub.com/vektah/gqlparser/compare/v2.5.11...v2.5.12)

##### What's Changed

- Disallow empty parens
([#&#8203;292](https://togithub.com/vektah/gqlparser/issues/292)). by
[@&#8203;yuchenshi](https://togithub.com/yuchenshi) in
[https://github.com/vektah/gqlparser/pull/293](https://togithub.com/vektah/gqlparser/pull/293)
- WithBuiltin FormatterOption added by
[@&#8203;atzedus](https://togithub.com/atzedus) in
[https://github.com/vektah/gqlparser/pull/294](https://togithub.com/vektah/gqlparser/pull/294)
- Redo github actions by
[@&#8203;StevenACoffman](https://togithub.com/StevenACoffman) in
[https://github.com/vektah/gqlparser/pull/295](https://togithub.com/vektah/gqlparser/pull/295)
- Bump github.com/stretchr/testify from 1.4.0 to 1.9.0 in the
actions-deps group by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[https://github.com/vektah/gqlparser/pull/296](https://togithub.com/vektah/gqlparser/pull/296)
- Bump the actions-deps group in /validator/imported with 8 updates by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[https://github.com/vektah/gqlparser/pull/297](https://togithub.com/vektah/gqlparser/pull/297)

##### New Contributors

- [@&#8203;yuchenshi](https://togithub.com/yuchenshi) made their first
contribution in
[https://github.com/vektah/gqlparser/pull/293](https://togithub.com/vektah/gqlparser/pull/293)

**Full Changelog**:
vektah/gqlparser@v2.5.11...v2.5.12

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "" (UTC), Automerge - At any time (no
schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR was generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View the
[repository job log](https://developer.mend.io/github/infratographer/x).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOC4xOC4xNyIsInVwZGF0ZWRJblZlciI6IjM4LjE4LjE3IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
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.

4 participants