Skip to content

Parser vulnerable to Trojan Source attack #12352

@joshuapassos

Description

@joshuapassos

Recently paper called Trojan Source: Invisible Vulnerabilities demonstrates an attack against source code. It uses Unicode bi-direcional overrides to misguide the meaning of code to a human reader.

Repro steps

let access_level = "user"

[<EntryPoint>]
let main _ =
  if access_level <> "user‮⁦ (* Check if admin *)⁩⁦" then
    printf "You are an admin.\n"
  0

Only selecting text with mouse over condicional that is possible see some different thing.

Here I have an example to reproduce the problem

Expected behavior

Maybe compiler error which message Invalid unicode character

Actual behavior

You are an admin.

Known workarounds

I don't know

Related information
Crystal lang discussion about this: crystal-lang/crystal#11392
Site about the problem: https://trojansource.codes/

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    New

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions