C# reference: one payload nesting bound (256) on read and write, nil arm slots refused, bounds vectors
CultPayloadDepth.Check walks MessagePack headers iteratively and refuses the first container past CultMessagePackSecurity.MaximumPayloadDepth, read or skipped, called by SerializeUntyped (on the bytes it produced) and DeserializeUntyped (before decoding). UntrustedData's 500 is replaced by the same value as a backstop. CultUnionGuard refuses [k, nil] arms. New vectors in tests/vectors/union-parity, with bounds-outcomes.msgpack as their data; the gate now runs every Check-calling test body and fingerprints bytes and write times. All commits build. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
624fff4f89
commit
abf624ab04
20 changed files with 465 additions and 21 deletions
|
|
@ -7,7 +7,15 @@ namespace GameCult.Caching.MessagePack;
|
|||
// UntrustedData, plus a collision-resistant comparer for CultRecordRef<T> dictionary keys over the key string.
|
||||
public sealed class CultMessagePackSecurity : MessagePackSecurity
|
||||
{
|
||||
public static readonly CultMessagePackSecurity Instance = new(UntrustedData);
|
||||
/// <summary>
|
||||
/// The deepest a document payload may nest, on read and on write, in every CultCache runtime: every MessagePack array and
|
||||
/// map counts, read by a formatter or skipped past it, and the outermost array is depth 1. A payload of this depth is
|
||||
/// accepted and one container deeper is refused. MessagePack's own object-graph counter is set to the same value as a
|
||||
/// backstop; the rule itself is <c>CultPayloadDepth.Check</c>, run by the document serialization entry points.
|
||||
/// </summary>
|
||||
public const int MaximumPayloadDepth = 256;
|
||||
|
||||
public static readonly CultMessagePackSecurity Instance = new(UntrustedData.WithMaximumObjectGraphDepth(MaximumPayloadDepth));
|
||||
|
||||
private CultMessagePackSecurity(MessagePackSecurity copyFrom) : base(copyFrom) { }
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue