Skip to content

Conversation

@dmihalcik-virtru
Copy link
Member

@dmihalcik-virtru dmihalcik-virtru commented Aug 19, 2024

This commit limits TDF Manifest sizes to 10MB or smaller. Prior to this fix, a protocol attack is possible to define a large manifest size which will result in a large memory allocation (even if the manifest transmitted is substantially smaller).

This commit also includes the fuzz testing that was used to discover this flaw.

In reader the Manifest load uses the function ReadAllFileData. This function is documented to only be used on small files, however to accomplish that a call to ReadFileSize beforehand would be necessary.

Because the call to check the defined size is likely to be missed, this commit updates ReadAllFileData to instead accept the maximum size as an argument, which is validated before allocating the byte slice.

Fixes #1391

@dmihalcik-virtru dmihalcik-virtru requested review from a team as code owners August 19, 2024 18:57
This commit fixes GHSA-9m35-5v9f-8x2j by limiting TDF Manifest sizes to 10MB or smaller.  Prior to this fix, a protocol attack is possible to define a large manifest size which will result in a large memory allocation (even if the manifest transmitted is substantially smaller).

This commit also includes the fuzz testing that was used to discover this flaw.

In `reader` the Manifest load uses the function `ReadAllFileData`.  This function is documented to only be used on small files, however to accomplish that a call to `ReadFileSize` beforehand would be necessary.

Because the call to check the defined size is likely to be missed, this commit updates `ReadAllFileData` to instead accept the maximum size as an argument, which is validated before allocating the byte slice.
jentfoo
jentfoo previously approved these changes Aug 19, 2024
- still doesn't assert much, just that either error exists or doesn't really, which isn't very helpful
@dmihalcik-virtru dmihalcik-virtru changed the title Reduce DoS risk by limiting TDF Manifest to 10MB fix(sdk) Reduce DoS risk by limiting TDF Manifest to 10MB Aug 19, 2024
@dmihalcik-virtru dmihalcik-virtru changed the title fix(sdk) Reduce DoS risk by limiting TDF Manifest to 10MB fix(sdk): During read, limits TDF Manifest to 10MB Aug 19, 2024
@dmihalcik-virtru dmihalcik-virtru changed the title fix(sdk): During read, limits TDF Manifest to 10MB fix(sdk): 🔒 During read, limits TDF Manifest to 10MB Aug 19, 2024
@dmihalcik-virtru
Copy link
Member Author

@jentfoo Can you take a look and make sure I haven't introduced any issues with my fixups?

Thanks!

- don't block on fuzz testing; instead we should run this on a schedule
- don't have complex 'valid value' checks on good output; not very useful, hard to maintain, and often slower than just running the test more
@jentfoo
Copy link
Contributor

jentfoo commented Aug 21, 2024

Thank you for the help @dmihalcik-virtru 🙌

@strantalis strantalis added this pull request to the merge queue Aug 21, 2024
Merged via the queue into main with commit cfeebce Aug 21, 2024
@strantalis strantalis deleted the feature/fuzzzzzzzzzz branch August 21, 2024 19:15
github-merge-queue bot pushed a commit that referenced this pull request Aug 21, 2024
🤖 I have created a release *beep* *boop*
---


##
[0.3.10](sdk/v0.3.9...sdk/v0.3.10)
(2024-08-21)


### Bug Fixes

* **sdk:** 🔒 During read, limits TDF Manifest to 10MB
([#1385](#1385))
([cfeebce](cfeebce))
* **sdk:** let value grants override attr grants
([#1318](#1318))
([77f1e11](77f1e11))
* **sdk:** well-known warning logs and public client id error
([#1415](#1415))
([e6e76bf](e6e76bf)),
closes [#1414](#1414)

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: opentdf-automation[bot] <149537512+opentdf-automation[bot]@users.noreply.github.com>
github-merge-queue bot pushed a commit that referenced this pull request Sep 4, 2024
This PR includes additional fuzzing and security testing that was not
covered in prior PR's (#1472 and #1385). Those PR's include the relevant
tests for their fixes, where this provides additional testing that was
explored but did not show issues.

In addition this PR includes some minor changes that were found while
reviewing the code base:
* Spelling fixes
* Token issue time and expiration based off the same time sample
(reduced kernel overheads and also ensures no time skew risks)

PR closes #1341
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.

ZTDF: validate size / length values before allocating buffers during read

4 participants