Skip to content

feat: restrict types allowed during deserialization via ITypeFilter#182

Merged
esskar merged 1 commit into
mainfrom
feature/issue-151-type-filter
Jun 16, 2026
Merged

feat: restrict types allowed during deserialization via ITypeFilter#182
esskar merged 1 commit into
mainfrom
feature/issue-151-type-filter

Conversation

@esskar

@esskar esskar commented Jun 16, 2026

Copy link
Copy Markdown
Owner

Add an opt-in type allow-list for expression deserialization, the equivalent of BinaryFormatter's SerializationBinder, so untrusted payloads cannot resolve arbitrary types.

  • ITypeFilter extension point on ExpressionContext (TypeFilter property
    • constructor overloads); enforced in ExpressionContextBase.ResolveType
  • Built-in AllowedTypesFilter (allow-list by type/open-generic/namespace) and DelegateTypeFilter (predicate)
  • TypeNotAllowedException thrown for rejected types
  • Filter applied on cache hits and to each generic argument, so it cannot be bypassed; no filter set keeps existing behavior unchanged
  • Add ExpressionSerializer.Deserialize(Stream, IExpressionContext) overload
  • Tests in Issues/Issue151.cs (90/90 passing)
  • Bump version to 4.3.0; update CHANGELOG and README

Closes #151

Add an opt-in type allow-list for expression deserialization, the
equivalent of BinaryFormatter's SerializationBinder, so untrusted
payloads cannot resolve arbitrary types.

- ITypeFilter extension point on ExpressionContext (TypeFilter property
  + constructor overloads); enforced in ExpressionContextBase.ResolveType
- Built-in AllowedTypesFilter (allow-list by type/open-generic/namespace)
  and DelegateTypeFilter (predicate)
- TypeNotAllowedException thrown for rejected types
- Filter applied on cache hits and to each generic argument, so it
  cannot be bypassed; no filter set keeps existing behavior unchanged
- Add ExpressionSerializer.Deserialize(Stream, IExpressionContext) overload
- Tests in Issues/Issue151.cs (90/90 passing)
- Bump version to 4.3.0; update CHANGELOG and README

Closes #151

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@esskar esskar merged commit fb62e34 into main Jun 16, 2026
1 check passed
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.

Question about deserialization security:

1 participant