Skip to content

[Bug][Security]: Lean character literal scanner accepts newlines, enabling code injection #865

Description

@morluto

Summary

_skip_quoted_literal advances through any character that isn't a backslash or the delimiter, including newlines. An input like by exact True.intro\n'\n#eval <IO action>\n' makes the scanner consume everything through the second quote, hiding the #eval directive from the proof-axiom validator.

Evidence

src/jacobian/lean_frontend/proof_axioms.py L371-380:

def _skip_quoted_literal(source: str, index: int, length: int, delimiter: str) -> int:
    index += 1
    while index < length:
        if source[index] == "\\":
            index += 2
        elif source[index] == delimiter:
            return index + 1
        else:
            index += 1
    return index

Root cause

The quoted-literal scanner has no newline rejection. Lean character literals are single-character and cannot contain raw newlines, so a newline inside a char literal is always malformed.

Scope

Reject newlines inside _skip_quoted_literal when the delimiter is ' (char literal), raising a malformed-literal error instead of consuming across lines.

Source

Generated with Devin

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1: highShould be addressed in the current or next iterationarea: kernelCore verification kernel and trust boundariesarea: securitySecurity, threat model, and trust boundariesbugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions