Skip to content

fix(sdk): DoS protection through TDF segment sizes#1536

Merged
jentfoo merged 1 commit into
mainfrom
jent/tdf_segment_size_fix
Sep 17, 2024
Merged

fix(sdk): DoS protection through TDF segment sizes#1536
jentfoo merged 1 commit into
mainfrom
jent/tdf_segment_size_fix

Conversation

@jentfoo

@jentfoo jentfoo commented Sep 10, 2024

Copy link
Copy Markdown
Contributor

This fixes three DoS conditions discovered:

  • Specifying a very large segment size which could result in the SDK allocating a large buffer in memory
  • Specifyin a very small segment size which could result in excessive cpu and io overheads
  • Specifying a size in the manifest which will overflow, resulting in a panic when a negative byte slice is allocated

Unit testing and fuzz testing was expanded to cover these conditions. This PR fixes #1535

@jentfoo jentfoo self-assigned this Sep 10, 2024
@jentfoo
jentfoo requested review from a team as code owners September 10, 2024 15:39
This fixes three DoS conditions discovered:
  * Specifying a very large segment size which could result in the SDK allocating a large buffer in memory
  * Specifyin a very small segment size which could result in excessive cpu and io overheads
  * Specifying a size in the manifest which will overflow, resulting in a `panic` when a negative byte slice is allocated

Unit and fuzz testing was expanded to cover these conditions.
@jentfoo
jentfoo force-pushed the jent/tdf_segment_size_fix branch from 68de773 to 643918a Compare September 10, 2024 16:59
Comment thread sdk/tdf_config.go
@dmihalcik-virtru

Copy link
Copy Markdown
Member

Following Postel's law, we should probably accept a wider range of values in decrypt than we allow in encrypt. Basically, anything that doesn't break the system should be acceptable on decrypt, for some suitable definition of break.

Comment thread sdk/tdf_config.go
@jentfoo
jentfoo added this pull request to the merge queue Sep 17, 2024
Merged via the queue into main with commit d506734 Sep 17, 2024
@jentfoo
jentfoo deleted the jent/tdf_segment_size_fix branch September 17, 2024 18:45
github-merge-queue Bot pushed a commit that referenced this pull request Oct 1, 2024
🤖 I have created a release *beep* *boop*
---


##
[0.3.13](sdk/v0.3.12...sdk/v0.3.13)
(2024-10-01)


### Features

* **sdk:** Add namesapce grants to key splitting
([#1512](#1512))
([d9a07f8](d9a07f8))


### Bug Fixes

* **ci:** Fix negative assertion test case false positive
([#1550](#1550))
([ef40bdb](ef40bdb))
* **core:** Add NanoTDF KID padding removal and update logging level
([#1466](#1466))
([54de8f4](54de8f4)),
closes [#1467](#1467)
* **core:** Autobump sdk
([#1513](#1513))
([03fba13](03fba13))
* **core:** Autobump sdk
([#1577](#1577))
([df7466b](df7466b))
* **core:** only strip nano kids to the right
([#1475](#1475))
([ae8d8a2](ae8d8a2))
* **core:** Store attribute specific grants to key cache
([#1507](#1507))
([8bc0a98](8bc0a98))
* **sdk:** DoS protection through TDF segment sizes
([#1536](#1536))
([d506734](d506734))
* **sdk:** Fix nanotdf ECC mode bitfield
([#1551](#1551))
([58a76ad](58a76ad))
* **sdk:** Fix possible panic for `AttributeValueFQN.Prefix()`
([#1472](#1472))
([144aeda](144aeda))
* **sdk:** Granter offline mode with namespaces and keycache
([#1542](#1542))
([ecd41f4](ecd41f4))

---
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>
jentfoo added a commit to opentdf/java-sdk that referenced this pull request Nov 27, 2024
This matches the protections introduced in the go SDK PR: opentdf/platform#1536
jentfoo added a commit to opentdf/java-sdk that referenced this pull request Nov 27, 2024
This matches the protections introduced in the go SDK PR: opentdf/platform#1536
jentfoo added a commit to opentdf/java-sdk that referenced this pull request Dec 3, 2024
This matches the protections introduced in the go SDK PR: opentdf/platform#1536
jentfoo added a commit to opentdf/java-sdk that referenced this pull request Dec 4, 2024
This change includes a variety of fixes found with fuzz testing.

* Protocol Exception improvements - `NullPointerExceptions` have been
converted to other exception types. Please provde feedback on if other
exception types should be used for these cases. In `Fuzzing.java` now
also serves to define in testing what exception types are acceptable.
The `catch` specifically lists the types of exceptions that were
discovered for each API call, and `throws` are checked exceptions that
are not expected to be possible. As a future improvement we may want to
refine this list further and better document what exceptions happen
under what conditions. For now I thought it was best to start with just
the `NullPointerException` cases. Since these cases were numerous, these
changes span multiple commits, with each commit focused on a specific
area of the protocol.
* Protocol DoS Fixes - The only memory consumption issue discovered was
the [counterpart found in the go
sdk](opentdf/platform#1536). A matching fix with
the same defaults was implemented here in the java sdk.
* Finally the testing itself is added as `Fuzzing.java` executed through
`sdk/fuzz.sh`. This script is long running, and there are occasional
Jazzer failures which are not believed to be real deficiencies (timeouts
when `.position()` is called on the stream). For that reason this
testing needs to be done manually, and not expected to be included in CI
* A few optimizations and clarity improvements were also included, as
they were noticed while generally trying to get familiar with the
codebase.
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.

Possible DoS through abuse of segment sizes in TDF

2 participants