{"id":"CVE-2026-74791","aliases":["CVE-2026-74791","GHSA-x6m9-38vm-2xhf"],"related":[],"kind":"vulnerability","state":"published","title":"Scriban before 7.0.0 Authorization Bypass via Stale Include Cache","summary":"Scriban before 7.0.0 fails to clear the CachedTemplates dictionary when TemplateContext.Reset() is called, allowing cached templates to persist across reused contexts. Attackers can exploit request-dependent ITemplateLoader implementations to access previously authorized template content from earlier renders without triggering TemplateLoader.Load() again.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"Scriban before 7.0.0 fails to clear the CachedTemplates dictionary when TemplateContext.Reset() is called, allowing cached templates to persist across reused contexts. Attackers can exploit request-dependent ITemplateLoader implementations to access previously authorized template content from earlier renders without triggering TemplateLoader.Load() again.","source":"cvelist"},{"lang":"en","text":"## Summary\n\n`TemplateContext.Reset()` claims that a `TemplateContext` can be reused safely on the same thread, but it does not clear `CachedTemplates`. If an application pools `TemplateContext` objects and uses an `ITemplateLoader` that resolves content per request, tenant, or user, a previously authorized include can be served to later renders without calling `TemplateLoader.Load()` again.\n\n## Details\n\nThe relevant code path is:\n\n- `TemplateContext.Reset()` only clears output, globals, cultures, and source files in `src/Scriban/TemplateContext.cs` lines 877–902.\n- `CachedTemplates` is initialized once and kept on the context in `src/Scriban/TemplateContext.cs` line 197.\n- `include` resolves templates through `IncludeFunction.Invoke()` in `src/Scriban/Functions/IncludeFunction.cs` lines 29–43.\n- `IncludeFunction.Invoke()` calls `TemplateContext.GetOrCreateTemplate()` in `src/Scriban/TemplateContext.cs` lines 1249–1256.\n- If a template path is already present in `CachedTemplates`, Scriban returns the cached compiled template and does **not** call `TemplateLoader.Load()` again.\n\nThis becomes a security issue when `ITemplateLoader.Load()` returns request-dependent content. A first render can prime the cache with an admin-only or tenant-specific template, and later renders on the same reused `TemplateContext` will receive that stale template even after `Reset()`.\n\n---\n\n## Proof of Concept\n\n### Setup\n\n```bash\nmkdir scriban-poc1\ncd scriban-poc1\ndotnet new console --framework net8.0\ndotnet add package Scriban --version 6.6.0\n```\n\n### `Program.cs`\n\n```csharp\nusing Scriban;\nusing Scriban.Parsing;\nusing Scriban.Runtime;\n\nvar loader = new SwitchingLoader();\nvar context = new TemplateContext\n{\n    TemplateLoader = loader,\n};\n\nvar template = Template.Parse(\"{{ include 'profile' }}\");\n\nloader.Content = \"admin-only\";\nConsole.WriteLine(\"first=\" + template.Render(context));\n\ncontext.Reset();\n\nloader.Content = \"guest-view\";\nConsole.WriteLine(\"second=\" + template.Render(context));\n\nsealed class SwitchingLoader : ITemplateLoader\n{\n    public string Content { get; set; } = string.Empty;\n\n    public string GetPath(TemplateContext context, SourceSpan callerSpan, string templateName) => templateName;\n\n    public string Load(TemplateContext context, SourceSpan callerSpan, string templatePath) => Content;\n\n    public ValueTask<string> LoadAsync(TemplateContext context, SourceSpan callerSpan, string templatePath)\n        => new(Content);\n}\n```\n\n### Run\n\n```bash\ndotnet run\n```\n\n### Actual Output\n\n```\nfirst=admin-only\nsecond=admin-only\n```\n\n### Expected Output\n\n```\nfirst=admin-only\nsecond=guest-view\n```\n\nThe second render should reload the template after `Reset()`, but it instead reuses the cached compiled template from the previous render.\n\n---\n\n## Impact\n\nThis is a cross-render data isolation issue. Any application that reuses `TemplateContext` objects and uses a request-dependent `ITemplateLoader` can leak previously authorized template content across requests, users, or tenants.\n\nThe issue impacts applications that:\n\n- Pool or reuse `TemplateContext`\n- Call `Reset()` between requests\n- Use `include`\n- Resolve include content based on request-specific state","format":"markdown","source":"ghsa"}],"published":"2026-03-24T22:09:49.000Z","modified":"2026-08-31T20:30:14.457Z","severity":{"scorer":"VulnCheck","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:N/VA:N/SC:H/SI:N/SA:N","score":9.2,"rating":"CRITICAL"},"severities":[{"scorer":"VulnCheck","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:N/VA:N/SC:H/SI:N/SA:N","score":9.2,"rating":"CRITICAL"},{"scorer":"VulnCheck","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:N/A:N","score":8.6,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:N/A:N","score":8.6,"rating":"HIGH"}],"cwes":["CWE-226"],"affected":[{"ranges":[{"type":"semver","introduced":"0","fixed":"7.0.0","status":"affected"},{"type":"semver","version":"7.0.0","status":"unaffected"}],"vendor":"scriban","product":"scriban","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"7.0.0"}],"ecosystem":"NuGet","package":"scriban","purl":"pkg:nuget/scriban","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"7.0.0"}],"ecosystem":"NuGet","package":"Scriban.Signed","purl":"pkg:nuget/Scriban.Signed","source":"ghsa"}],"references":[{"url":"https://github.com/scriban/scriban/security/advisories/GHSA-x6m9-38vm-2xhf","tags":["exploit","vendor-advisory","web"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://www.vulncheck.com/advisories/scriban-before-authorization-bypass-via-stale-include-cache","tags":["third-party-advisory"],"sources":["cvelist","nvd"]},{"url":"https://github.com/scriban/scriban","tags":["package"],"sources":["ghsa"]}],"credits":["Zwique"],"assigner":"VulnCheck","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"yes","technicalImpact":"partial","date":"2026-08-17T17:40:57.646Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-74791","url":"https://www.cve.org/CVERecord?id=CVE-2026-74791","licence":"CVE Terms of Use","modified":"2026-08-17T17:41:05.149Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-x6m9-38vm-2xhf","url":"https://github.com/advisories/GHSA-x6m9-38vm-2xhf","licence":"CC-BY-4.0","modified":"2026-08-17T03:55:59.456Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-74791","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-74791","licence":"Public domain","modified":"2026-08-31T20:30:14.457Z"}],"updatedAt":"2026-11-25T22:59:33.308Z","epss":{"score":0.00269,"percentile":0.20399,"date":"2026-12-01T12:00:22.000Z"}}