GHSA-5wr9-m6jw-xx44

Suggest an improvement
Source
https://github.com/advisories/GHSA-5wr9-m6jw-xx44
Import Source
https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/03/GHSA-5wr9-m6jw-xx44/GHSA-5wr9-m6jw-xx44.json
JSON Data
https://api.osv.dev/v1/vulns/GHSA-5wr9-m6jw-xx44
Published
2026-03-24T22:11:38Z
Modified
2026-03-24T23:10:34.321806Z
Severity
  • 9.1 (Critical) CVSS_V3 - CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N CVSS Calculator
Summary
Scriban: Sandbox escape due to TypedObjectAccessorcache bypassing MemberFilter after TemplateContext reuse
Details

Summary

TemplateContext caches type accessors by Type only, but those accessors are built using the current MemberFilter and MemberRenamer. When a TemplateContext is reused and the filter is tightened for a later render, Scriban still reuses the old accessor and continues exposing members that should now be hidden.

Details

The relevant code path is:

  • TemplateContext.GetMemberAccessor() caches accessors in _memberAccessors by Type in src/Scriban/TemplateContext.cs lines 850–863.
  • For plain .NET objects, GetMemberAccessorImpl() creates a new TypedObjectAccessor(type, _keyComparer, MemberFilter, MemberRenamer) in src/Scriban/TemplateContext.cs lines 909–939.
  • TypedObjectAccessor stores the current filter and precomputes the exposed member set in its constructor and PrepareMembers() in src/Scriban/Runtime/Accessors/TypedObjectAccessor.cs lines 33–40 and 119–179.
  • Member access later goes through ScriptMemberExpression.GetValue() in src/Scriban/Syntax/Expressions/ScriptMemberExpression.cs lines 67–95, which uses the cached accessor.
  • TemplateContext.Reset() does not clear _memberAccessors in src/Scriban/TemplateContext.cs lines 877–902.

As a result, once a permissive accessor has been created for a given type, changing TemplateContext.MemberFilter later does not take effect for that type on the same reused context.

This is especially relevant because the Scriban docs explicitly recommend TemplateContext.MemberFilter for indirect .NET object exposure.


Proof of Concept

Setup

mkdir scriban-poc2
cd scriban-poc2
dotnet new console --framework net8.0
dotnet add package Scriban --version 6.6.0

Program.cs

using System.Reflection;
using Scriban;
using Scriban.Runtime;

var template = Template.Parse("{{ model.secret }}");

var context = new TemplateContext
{
    EnableRelaxedMemberAccess = false
};

var globals = new ScriptObject();
globals["model"] = new SensitiveModel();
context.PushGlobal(globals);

context.MemberFilter = _ => true;
Console.WriteLine("first=" + template.Render(context));

context.Reset();

var globals2 = new ScriptObject();
globals2["model"] = new SensitiveModel();
context.PushGlobal(globals2);

context.MemberFilter = member => member.Name == nameof(SensitiveModel.Public);

Console.WriteLine("second=" + template.Render(context));

sealed class SensitiveModel
{
    public string Public => "ok";
    public string Secret => "leaked";
}

Run

dotnet run

Actual Output

first=leaked
second=leaked

Expected Behavior

The second render should fail or stop exposing Secret, because the filter only allows Public and EnableRelaxedMemberAccess is disabled.

This reproduces a direct filter bypass caused by the stale cached accessor.


Impact

This is a protection-mechanism bypass. Applications that use TemplateContext.MemberFilter as part of their sandbox or object-exposure policy can unintentionally expose hidden members across requests when they reuse a TemplateContext.

The impact includes:

  • Unauthorized read access to filtered properties or fields
  • Unauthorized writes if the filtered member also has a setter
  • Policy bypass across requests, users, or tenants when contexts are pooled
Database specific
{
    "cwe_ids": [
        "CWE-693"
    ],
    "severity": "CRITICAL",
    "github_reviewed": true,
    "nvd_published_at": null,
    "github_reviewed_at": "2026-03-24T22:11:38Z"
}
References

Affected packages

NuGet / scriban

Package

Affected ranges

Type
ECOSYSTEM
Events
Introduced
0Unknown introduced version / All previous versions are affected
Fixed
7.0.0

Affected versions

0.*
0.1.0
0.2.0
0.2.1
0.2.2
0.3.0
0.3.1-pre028
0.3.1
0.4.0
0.5.0
0.6.0
0.7.0
0.9.0-pre100
0.9.0
0.9.1
0.10.0
0.11.0
0.12.0
0.12.1
0.13.0
0.14.0
0.15.0
0.16.0
1.*
1.0.0-beta-001
1.0.0-beta-002
1.0.0-beta-003
1.0.0-beta-004
1.0.0-beta-005
1.0.0-beta-006
1.0.0
1.1.0
1.1.1
1.2.0
1.2.1
1.2.2
1.2.3
1.2.4
1.2.5
1.2.6
1.2.7
1.2.8
1.2.9
2.*
2.0.0-alpha-001
2.0.0-alpha-002
2.0.0-alpha-003
2.0.0-alpha-004
2.0.0-alpha-005
2.0.0-alpha-006
2.0.0
2.0.1
2.1.0
2.1.1
2.1.2
2.1.3
2.1.4
3.*
3.0.0
3.0.1
3.0.2
3.0.3
3.0.4
3.0.5
3.0.6
3.0.7
3.1.0
3.2.0
3.2.1
3.2.2
3.3.0
3.3.1
3.3.2
3.3.3
3.4.0
3.4.1
3.4.2
3.5.0
3.6.0
3.7.0
3.8.0
3.8.1
3.8.2
3.9.0
4.*
4.0.0
4.0.1
4.0.2
4.1.0
5.*
5.0.0
5.1.0
5.2.0
5.3.0
5.4.0
5.4.1
5.4.2
5.4.3
5.4.4
5.4.5
5.4.6
5.5.0
5.5.1
5.5.2
5.6.0
5.7.0
5.8.0
5.9.0
5.9.1
5.10.0
5.11.0
5.12.0
5.12.1
6.*
6.0.0
6.1.0
6.2.0
6.2.1
6.3.0
6.4.0
6.5.0
6.5.1
6.5.2
6.5.3
6.5.4
6.5.5
6.5.6
6.5.7
6.5.8
6.6.0

Database specific

source
"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/03/GHSA-5wr9-m6jw-xx44/GHSA-5wr9-m6jw-xx44.json"