Commit 500a3a6
committed
Render Jinja templates in a sandbox to clear SSTI BLOCKER
SonarCloud pythonsecurity:S5496 flags env.from_string(template).render(...)
as server-side template injection when the template string is reachable from
user input. Switching the Environment to ImmutableSandboxedEnvironment is
the canonical Jinja2 mitigation: attribute access to Python internals
(__class__, __globals__, __mro__, mutating passed collections, …) raises
SecurityError, so a caller that accepts untrusted templates cannot escape.
autoescape stays True unconditionally; the Markup-based opt-out path for
non-HTML output is unchanged.1 parent c352c48 commit 500a3a6
1 file changed
+9
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
96 | | - | |
| 96 | + | |
97 | 97 | | |
| 98 | + | |
98 | 99 | | |
99 | 100 | | |
100 | 101 | | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
106 | 109 | | |
107 | 110 | | |
108 | 111 | | |
| |||
0 commit comments