Skip to content

Rework Code Evaluation #195

@mbaruh

Description

@mbaruh

Currently the code evaluation suffers from possible exploits. These stem from how code evaluation currently works on the forms app:

  1. The user's code, as well as the pre-supplied unit tests, are sent to snekbox.
  2. The unit tests are run on the user's code inside snekbox.
  3. The result of the tests are supplied back from snekbox through stdout.

This means that if the user manages to control the stdout, they are able to control the output of the tests, as far as the forms app can understand it.

There are several means in place already to mitigate this issue, but to solve it, this ultimately requires a more thorough/drastic solution.

Solution 1

Separate user code from the tests.

  • The user code alone will be sent to snekbox.
  • The result of the user's code will be fed to stdout.
  • The stdout will be read from snekbox.
  • The output will be compared to a pre-supplied string to check whether the user's code passes (similarly to how it works in Code Wars).

This has the disadvantage of limiting what we can evaluate, as currently we are able to inspect Python objects during testing.

Solution 2

We can see whether we can add an additional way to supply information from snekbox, specifically for the purpose of getting test responses. For example via an encrypted byte-stream. Either way something that can't be accessed from the evaluated code. The details can be hashed out if this is something we want to do.

In any case, considering the protections we already have in place against something like that, and considering Code Jam qualifiers are meant to assess a person's Python knowledge, even if someone is able to exploit the current system, it's not the worst thing in the world (although preferrably it wouldn't happen anyway). Therefore, this issue should be relatively low priority.

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