Skip to content

Commit 43cee1b

Browse files
author
LoCoBench Bot
committed
Merge remote-tracking branch 'origin/ralph/gapfill-security'
# Conflicts: # configs/codereview_2config.sh # configs/selected_benchmark_tasks.json # prd.json
2 parents 7b66842 + a6e80da commit 43cee1b

File tree

52 files changed

+4113
-177
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+4113
-177
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
FROM debian:bookworm-slim
2+
3+
WORKDIR /workspace
4+
5+
# Install dependencies
6+
RUN apt-get update && apt-get install -y \
7+
git \
8+
curl \
9+
python3 \
10+
npm \
11+
build-essential \
12+
&& rm -rf /var/lib/apt/lists/*
13+
14+
# Install Claude Code CLI
15+
RUN npm install -g @anthropic-ai/claude-code
16+
17+
# Clone curl at the pre-fix commit (vulnerable code present)
18+
# Parent of fix commit fb4415d8aee6c1045be932a34fe6107c2f5ed147
19+
RUN git clone --filter=blob:none --no-checkout https://github.com/curl/curl.git . && \
20+
git checkout 09e25b9d94f4106eac8ca3a43b221bdc66f405e4 && \
21+
git config user.email "agent@example.com" && \
22+
git config user.name "Agent"
23+
24+
# Create output directories
25+
RUN mkdir -p /logs/agent /logs/verifier
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# CVE Triage: curl SOCKS5 Heap Buffer Overflow (CVE-2023-38545)
2+
3+
**Repository:** curl/curl
4+
**Task Type:** CVE Triage (analysis only — no code fixes)
5+
6+
## Security Advisory
7+
8+
**CVE ID:** CVE-2023-38545
9+
**Severity:** HIGH (CVSS 9.8)
10+
**CWE:** CWE-122 (Heap-based Buffer Overflow)
11+
**Affected Versions:** libcurl 7.69.0 through 8.3.0
12+
13+
### Description
14+
15+
This flaw makes curl overflow a heap based buffer in the SOCKS5 proxy handshake.
16+
17+
When curl is asked to pass along the hostname to the SOCKS5 proxy to allow that to resolve the address instead of it getting done by curl itself, the maximum length that hostname can be is 255 bytes.
18+
19+
If the hostname is detected to be longer than 255 bytes, curl switches to local name resolving and instead passes on the resolved address only to the proxy. Due to a bug, the local variable that means "let the host resolve the name" could get the wrong value during a slow SOCKS5 handshake, and contrary to the intention, copy the too long hostname to the target buffer instead of copying just the resolved address there.
20+
21+
The target buffer being a heap based buffer, and the hostname coming from the URL that curl has been told to operate with.
22+
23+
### Exploitation Conditions
24+
25+
An attacker must control an HTTPS server accessible by the client using libcurl. The client must:
26+
1. Use a SOCKS5 proxy in proxy-resolver mode
27+
2. Follow HTTP redirects (attacker provides a redirect to a URL with a hostname > 255 bytes)
28+
3. The SOCKS5 handshake must be slow enough to trigger the state machine bug
29+
30+
## Your Task
31+
32+
Locate the vulnerable code in this curl repository. You must identify:
33+
34+
1. **The specific source file** containing the vulnerability
35+
2. **The specific function** with the buffer overflow bug
36+
3. **The root cause** — which variable or state machine logic causes the overflow
37+
4. **The vulnerability type** — classify the bug (e.g., buffer overflow, integer overflow, use-after-free)
38+
5. **The attack surface** — which curl configurations trigger this code path
39+
40+
You are NOT told which file or function contains the bug. You must find it through code analysis.
41+
42+
## Output Requirements
43+
44+
Write your triage report to `/logs/agent/triage.md`.
45+
46+
Your report MUST include these sections:
47+
48+
```
49+
# Triage Report: CVE-2023-38545
50+
51+
## Summary
52+
<Vulnerability classification, severity, and 1-2 sentence finding>
53+
54+
## Affected Code
55+
<Specific file path(s), function name(s), and line number(s) containing the vulnerability>
56+
57+
## Root Cause
58+
<Technical explanation of the bug — what goes wrong and why>
59+
60+
## Attack Vector
61+
<How the vulnerability can be exploited, including entry points and preconditions>
62+
63+
## Severity Assessment
64+
<CVSS-style assessment: attack complexity, privileges required, user interaction>
65+
```
66+
67+
## Constraints
68+
69+
- Do NOT write any code fixes
70+
- Do NOT modify any source files
71+
- Your job is triage and analysis only
72+
- Focus on identifying the vulnerable code and explaining the root cause
73+
- The repository is checked out at a version where the vulnerable code is present
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
version = "1.0"
2+
3+
[metadata]
4+
name = "sec-cve-001"
5+
description = "Locate vulnerable code from curl SOCKS5 heap buffer overflow CVE"
6+
license = "Apache-2.0"
7+
8+
[task]
9+
id = "sec-cve-001"
10+
repo = "curl/curl"
11+
category = "cve_triage"
12+
language = "c"
13+
difficulty = "hard"
14+
time_limit_sec = 1200
15+
16+
[verification]
17+
type = "test"
18+
command = "bash /tests/test.sh"
19+
20+
reward_type = "checklist"
21+
description = "Weighted checklist scoring triage report against ground-truth findings"
22+
23+
[environment]
24+
build_timeout_sec = 600.0
25+
26+
[environment.setup_scripts]
27+
mcp_config = """#!/bin/bash
28+
# Setup Sourcegraph MCP if credentials provided
29+
if [ -n "$SOURCEGRAPH_ACCESS_TOKEN" ] && [ -n "$SOURCEGRAPH_URL" ]; then
30+
echo "Setting up Sourcegraph MCP configuration..."
31+
mkdir -p /root/.config/claude
32+
33+
cat > /root/.config/claude/mcp.json << 'MCPEOF'
34+
{
35+
"mcpServers": {
36+
"sourcegraph": {
37+
"command": "npx",
38+
"args": ["-y", "@sourcegraph/mcp-server"],
39+
"env": {
40+
"SRC_ACCESS_TOKEN": "$SOURCEGRAPH_ACCESS_TOKEN",
41+
"SOURCEGRAPH_URL": "$SOURCEGRAPH_URL"
42+
}
43+
}
44+
}
45+
}
46+
MCPEOF
47+
48+
echo "MCP configuration created"
49+
else
50+
echo "No Sourcegraph credentials provided, MCP disabled"
51+
fi
52+
exit 0
53+
"""
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
{
2+
"task_id": "sec-cve-001",
3+
"description": "curl SOCKS5 heap buffer overflow CVE-2023-38545 triage",
4+
"weights": {
5+
"required_findings": 0.40,
6+
"file_references": 0.30,
7+
"causal_chain": 0.20,
8+
"negative_checks": 0.10
9+
},
10+
"required_findings": [
11+
{
12+
"id": "f1",
13+
"description": "Identifies the vulnerable function do_SOCKS5 or Curl_SOCKS5",
14+
"patterns": ["do_SOCKS5", "Curl_SOCKS5"],
15+
"weight": 0.25
16+
},
17+
{
18+
"id": "f2",
19+
"description": "Identifies heap buffer overflow vulnerability type",
20+
"patterns": ["heap.*buffer.*overflow", "buffer.*overflow.*heap", "heap.*overflow"],
21+
"weight": 0.20
22+
},
23+
{
24+
"id": "f3",
25+
"description": "Identifies the hostname length check (255 byte limit)",
26+
"patterns": ["255", "hostname.*len", "hostname_len"],
27+
"weight": 0.20
28+
},
29+
{
30+
"id": "f4",
31+
"description": "Identifies the socks5_resolve_local variable or state machine issue",
32+
"patterns": ["socks5_resolve_local", "resolve.*local", "state.*machine", "non.?blocking"],
33+
"weight": 0.20
34+
},
35+
{
36+
"id": "f5",
37+
"description": "Identifies SOCKS5 proxy handshake as the attack surface",
38+
"patterns": ["SOCKS5.*proxy|proxy.*SOCKS5", "SOCKS5.*handshake|handshake.*SOCKS5", "CURLPROXY_SOCKS5"],
39+
"weight": 0.15
40+
}
41+
],
42+
"file_references": [
43+
{
44+
"id": "r1",
45+
"description": "Identifies lib/socks.c as the vulnerable file",
46+
"patterns": ["lib/socks\\.c", "socks\\.c"],
47+
"weight": 0.50
48+
},
49+
{
50+
"id": "r2",
51+
"description": "Identifies lib/socks.h or SOCKS-related headers",
52+
"patterns": ["lib/socks\\.h", "socks\\.h", "lib/cf-socket"],
53+
"weight": 0.20
54+
},
55+
{
56+
"id": "r3",
57+
"description": "Identifies CONNECT_SOCKS_INIT or CONNECT_RESOLVE_REMOTE state",
58+
"patterns": ["CONNECT_SOCKS_INIT", "CONNECT_RESOLVE_REMOTE", "CONNECT_REQ_SEND"],
59+
"weight": 0.30
60+
}
61+
],
62+
"causal_chain": [
63+
{
64+
"id": "c1",
65+
"description": "Explains hostname > 255 bytes should trigger local resolve but state machine loses this decision",
66+
"patterns": ["hostname.*255|255.*hostname", "resolve.*local|local.*resolve", "state|re.?enter"],
67+
"ordered": true,
68+
"weight": 0.50
69+
},
70+
{
71+
"id": "c2",
72+
"description": "Explains that the oversized hostname gets copied into a fixed-size heap buffer",
73+
"patterns": ["hostname.*cop|cop.*hostname|memcpy|socksreq", "buffer|overflow|heap"],
74+
"ordered": true,
75+
"weight": 0.50
76+
}
77+
],
78+
"negative_checks": [
79+
{
80+
"id": "n1",
81+
"description": "Does NOT blame TLS/SSL layer for the vulnerability",
82+
"patterns": ["TLS.*cause|TLS.*root|SSL.*cause|SSL.*root|TLS.*vulnerab|SSL.*vulnerab"],
83+
"must_be_absent": true,
84+
"weight": 0.50
85+
},
86+
{
87+
"id": "n2",
88+
"description": "Does NOT blame HTTP parsing as the root cause",
89+
"patterns": ["HTTP.*pars.*root|HTTP.*pars.*cause|HTTP.*pars.*vulnerab"],
90+
"must_be_absent": true,
91+
"weight": 0.50
92+
}
93+
]
94+
}

0 commit comments

Comments
 (0)