Skip to content

filter ascii control chars for backspace #266

Open
@sqlalchemy-bot

Description

@sqlalchemy-bot

Migrated issue, originally created by jvanasco (@jvanasco)

I've opened a ticket/PR with Markupsafe for this, but wanted to alert Mako on this too as addressing this behavior may be warranted on other filters.

Most Python libraries for form validation or text sanitizing will let ASCII control characters through. If they make it to Mako, they are rendered in the template as-is, and wind up in web browsers as non-printing characters.

That allows a malicious actor to carefully construct a payload such as this:

import y\bose\bm\bi\bt\be\b 

which looks like this on an HTML page:

import yosemite

However all the backspace control characters are in there and will copy/paste into a Python/ruby/etc terminal, where they are interpreted in realtime and become...

import os

If Mako is used as the engine on a coding website or bug reporting system, this introduces a way of tricking users into executing seemingly safe code that is actually malicious.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions