Summary
Scriban contains an access-modifier bypass in its TypedObjectAccessor that can let template code write properties without respecting setter visibility. If an attacker can influence or execute templates with access to live CLR objects, they may alter private, internal, init-only, or publicly settable properties and persist unauthorized state changes.
Affected context
The issue occurs in applications that use Scriban to render templates while exposing CLR objects to template code. It becomes risky when template content is attacker-controlled or insufficiently trusted and the rendering context contains mutable host objects whose properties influence application behavior, authorization, configuration, or persisted state.
Exploit preconditions
- Attack surface: Scriban template evaluation with CLR objects available in the template context
- Required access: The ability to create, modify, or cause execution of a template in the affected rendering workflow
- Trigger point: Property assignment performed during template rendering
- Why exploitation is possible: TypedObjectAccessor permits writes without consistently enforcing setter visibility or initialization restrictions, allowing template code to modify properties that should not be writable
Why this happens
The vulnerability is caused by an access-control enforcement failure in the object-access layer used by template evaluation. Property writes are permitted without reliably checking whether the corresponding CLR setter is public, private, internal, or restricted to initialization, and broad assignment can also affect ordinary public-setter properties. This maps to CWE-284: Improper Access Control, because the template execution context does not adequately enforce the intended authority boundaries for object mutation.
Potential impact
- Application state may be modified without the intended authorization checks
- Private, internal, or init-only properties may be altered at runtime
- Security-relevant configuration or policy objects could be tampered with
- Persistent data integrity may be affected if modified objects are later stored
- Application behavior could be redirected or degraded
- Multi-tenant isolation or workflow assumptions may be weakened
General mitigation guidance
Mitigation generally focuses on reducing the authority granted to templates and enforcing property-write policy at a trusted boundary.
Common defensive patterns include:
- Exposing dedicated, immutable view models rather than live domain or service objects
- Allowing template access only to explicitly approved properties and operations
- Treating template content as untrusted input and separating it from privileged execution contexts
- Enforcing authorization and validation again before state changes are committed
- Avoiding reliance on private, internal, or init-only modifiers as the sole protection against template writes
- Running template rendering with least-privilege application identities and narrowly scoped data access
How teams detect issues like this
Organizations can detect this class of issue through:
- Static analysis and dependency review for template engines that expose reflective object access
- Code review checks for passing live mutable objects, services, or security-sensitive models into templates
- Tests that attempt writes to private, internal, init-only, and public properties and verify the intended policy
- Runtime audit logging for template-driven changes to sensitive application objects
- Policy enforcement that restricts template contexts to approved data-transfer or immutable types
- Automated security review tools that flag unrestricted reflection and dynamic property assignment

