Skip to content

Discovery: cap registered presentation size and raise the client response cap - #4597

Open
reinkrul wants to merge 4 commits into
masterfrom
fix/discovery-size-limits
Open

reinkrul wants to merge 4 commits into
masterfrom
fix/discovery-size-limits

Conversation

@reinkrul

@reinkrul reinkrul commented Sep 29, 2026 •

Copy link
Copy Markdown
Member

Part of #4596 (this PR covers items 1 and 2; streaming and paging remain open for debate there).

What

  • Server: registered Verifiable Presentations are limited to 128 KiB. Checked first in Module.verifyRegistration, returned as ErrInvalidPresentation so the server answers 400. Since the same function verifies downloaded entries, clients also ignore oversized entries from a misbehaving server.
  • Client: the Discovery Service client reads responses of up to 10 MiB from the operator-configured Discovery Server. The strict HTTP client's response cap is now a per-client setting (WithMaxResponseSize, default unchanged at 1 MiB); every constructor goes through one helper so none can end up without a cap.
  • Docs paragraph on the 128 KiB limit; release notes entry under Security.

Why

GET /discovery/{serviceID} returns every entry after the given timestamp in one response, and the client refused anything over 1 MiB, so a service whose list grew past a few hundred entries (about 65 with X509Credentials) could no longer be synced by a new node. Two deliberately padded registrations could do the same for everyone. Details and measurements in #4596.

Sizing

Value Basis
128 KiB per VP Measured X509Credential VP with a 3-level G4 chain: 16 KB; production estimate 20 to 27 KB per X509Credential. Leaves room for a presentation carrying several X509Credentials.
10 MiB per response Largest value that fits a 256 MB node with the current buffered parse (measured about 5x body size transient). At 128 KiB per VP that is 80 fully padded registrations, or roughly 400 to 500 real X509Credential ones.

Testing

  • http/client: raised versus default cap against a test server; option applied by all constructors.
  • discovery: Register rejects a padded VP with presentation exceeds maximum size of 131072 bytes.

Assisted by AI

… response cap

Registered Verifiable Presentations are now limited to 64 KiB, checked first in
verifyRegistration and returned as ErrInvalidPresentation (HTTP 400). Legitimate
registrations are a few KB; one carrying an X509Credential with a full
PKIoverheid chain is about 16 KB.

The Discovery Service client reads responses of up to 10 MiB from the
operator-configured Discovery Server, instead of the 1 MiB the strict HTTP
client applies to all other outbound calls. The cap is now a per-client setting
(WithMaxResponseSize), defaulting to the existing 1 MiB, and all constructors
go through one helper so none can end up without a cap.

Previously a client could no longer synchronize a service once a response
exceeded 1 MiB, which a few hundred registrations, or two deliberately padded
ones, could cause. The cap stays at 10 MiB because the response is buffered and
parsed in memory; streaming or paging to lift it further is tracked in #4596.

Part of #4596

Assisted by AI
@stevenvegt

Copy link
Copy Markdown
Member

64kb seems strict. You said this is around 4 x509 type VCs in a VP? In LSP x Nuts we have an inschrijfVC, mandateVC, OrgVC and others. Some of those are x509 signed. Would 128kb also work without causing problems? Your test start from 10mb right, so perhaps redo them with smaller sizes to see what would be still ok?

@stevenvegt

Copy link
Copy Markdown
Member

how does this VP size limitation relates to presentations used in access token requests? Should we do the same there?

Review feedback: 64 KiB is tight for presentations carrying several
X509Credentials (about 16 KB each). 128 KiB still bounds a padded
registration well below the 10 MiB client response cap.

Assisted by AI
@qltysh

qltysh Bot commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

1 new issue

Tool Category Rule Count
qlty Structure Function with many returns (count = 11): verifyRegistration 1

@reinkrul
reinkrul marked this pull request as draft September 30, 2026 13:21
Reverts 5850d3a. A discovery registration carries the credentials the
service definition's presentation definition asks for, typically one
organization credential plus the registration credential; measured with
the did:x509 toolkit output that is 16 KB with one x509-signed credential,
30 KB with two and 45 KB with three, so 64 KiB leaves room for a second
organization-type credential. The multi-credential presentations from the
review discussion are used in access token requests, which this change
does not cap.

Assisted by AI
@reinkrul

reinkrul commented Oct 2, 2026

Copy link
Copy Markdown
Member Author

how does this VP size limitation relates to presentations used in access token requests? Should we do the same there?

It doesn't, I'll investigate that separately

@reinkrul

reinkrul commented Oct 2, 2026

Copy link
Copy Markdown
Member Author

64kb seems strict. You said this is around 4 x509 type VCs in a VP? In LSP x Nuts we have an inschrijfVC, mandateVC, OrgVC and others. Some of those are x509 signed. Would 128kb also work without causing problems? Your test start from 10mb right, so perhaps redo them with smaller sizes to see what would be still ok?

Those aren't credentials that are registered in the discovery service, but access-token-time credentials. We have some use cases that want a separate healthcare provider type-credential, we'll accommodate that comfortably with 64kb cap. If there are use cases that design something that won't fit in the current cap strategy, we can always revise it, but we'll cross that bridge when we get there.

@reinkrul
reinkrul marked this pull request as ready for review October 2, 2026 10:37

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants