Skip to content

Commit a0e5147

Browse files
author
server
committed
safekeeping
1 parent 7b3f91f commit a0e5147

31 files changed

Lines changed: 2744 additions & 353 deletions

Scripts/extract-crash-js.sh

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
#!/usr/bin/env bash
2+
# Extract lifted JavaScript for a program (crash) hash from the Fuzzilli Postgres DB.
3+
#
4+
# Usage:
5+
# ./Scripts/extract-crash-js.sh <program_hash> [output.js]
6+
#
7+
# If output.js is omitted, writes to crashes/<program_hash>.js under the repo root.
8+
#
9+
# Environment (optional):
10+
# POSTGRES_URL e.g. postgresql://user:pass@host:5432/dbname
11+
# DB_HOST, DB_PORT, DB_NAME, DB_USER, DB_PASSWORD (defaults match fuzzer-stats.sh)
12+
# FUZZILTOOL path to FuzzILTool (default: <repo>/.build/debug/FuzzILTool)
13+
# VERIFY_CRASH=1 require at least one crashed execution for this hash
14+
15+
set -euo pipefail
16+
17+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
18+
PROJECT_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"
19+
20+
if [ -f "${PROJECT_ROOT}/.env" ]; then
21+
# shellcheck source=/dev/null
22+
source "${PROJECT_ROOT}/.env"
23+
elif [ -f "${PROJECT_ROOT}/env.distributed" ]; then
24+
# shellcheck source=/dev/null
25+
source "${PROJECT_ROOT}/env.distributed"
26+
fi
27+
28+
DB_HOST="${DB_HOST:-localhost}"
29+
DB_PORT="${DB_PORT:-5432}"
30+
DB_NAME="${DB_NAME:-fuzzilli_master}"
31+
DB_USER="${DB_USER:-fuzzilli}"
32+
DB_PASSWORD="${DB_PASSWORD:-fuzzilli123}"
33+
34+
FUZZILTOOL="${FUZZILTOOL:-${PROJECT_ROOT}/.build/debug/FuzzILTool}"
35+
36+
usage() {
37+
echo "Usage: $0 <program_hash> [output.js]" >&2
38+
echo " program_hash: 64-char hex sha256 from program / crash records" >&2
39+
echo " output.js: optional path (default: crashes/<program_hash>.js)" >&2
40+
exit 1
41+
}
42+
43+
if [ "${1:-}" = "-h" ] || [ "${1:-}" = "--help" ]; then
44+
usage
45+
fi
46+
47+
HASH="${1:-}"
48+
OUTFILE="${2:-}"
49+
50+
if [ -z "$HASH" ]; then
51+
usage
52+
fi
53+
54+
if ! [[ "$HASH" =~ ^[0-9a-fA-F]{64}$ ]]; then
55+
echo "Error: program_hash must be 64 hex characters, got: $HASH" >&2
56+
exit 1
57+
fi
58+
59+
HASH_LC="$(echo "$HASH" | tr '[:upper:]' '[:lower:]')"
60+
61+
if [ ! -x "$FUZZILTOOL" ]; then
62+
echo "Error: FuzzILTool not found or not executable: $FUZZILTOOL" >&2
63+
echo "Set FUZZILTOOL or build: swift build" >&2
64+
exit 1
65+
fi
66+
67+
run_psql() {
68+
local sql="$1"
69+
if [ -n "${POSTGRES_URL:-}" ]; then
70+
psql "$POSTGRES_URL" -t -A -c "$sql"
71+
else
72+
PGPASSWORD="$DB_PASSWORD" psql -h "$DB_HOST" -p "$DB_PORT" -U "$DB_USER" -d "$DB_NAME" -t -A -c "$sql"
73+
fi
74+
}
75+
76+
if [ "${VERIFY_CRASH:-0}" = "1" ]; then
77+
crash_count="$(run_psql "SELECT COUNT(*)::text FROM execution WHERE program_hash = '$HASH_LC' AND execution_outcome_id = 1;" | tr -d '[:space:]')"
78+
if [ "${crash_count:-0}" = "0" ]; then
79+
echo "Error: no crashed execution (outcome 1) for hash $HASH_LC (set VERIFY_CRASH=0 to skip)" >&2
80+
exit 1
81+
fi
82+
fi
83+
84+
b64="$(run_psql "SELECT program_base64 FROM program WHERE program_hash = '$HASH_LC' LIMIT 1;" | tr -d '[:space:]')"
85+
86+
if [ -z "$b64" ]; then
87+
echo "Error: no program row for hash $HASH_LC" >&2
88+
exit 1
89+
fi
90+
91+
WORKDIR="$(mktemp -d "${TMPDIR:-/tmp}/extract-crash-js.XXXXXX")"
92+
cleanup() { rm -rf "$WORKDIR"; }
93+
trap cleanup EXIT
94+
95+
echo "$b64" | tr -d '[:space:]' | base64 --decode > "${WORKDIR}/program.fzil"
96+
97+
if [ -z "$OUTFILE" ]; then
98+
mkdir -p "${PROJECT_ROOT}/crashes"
99+
OUTFILE="${PROJECT_ROOT}/crashes/${HASH_LC}.js"
100+
fi
101+
102+
"$FUZZILTOOL" --liftToJS "${WORKDIR}/program.fzil" > "$OUTFILE"
103+
104+
echo "Wrote $OUTFILE"

Scripts/minimize-flags.sh

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ set -e
88
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
99
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
1010
CRASH_JS="${1:-$SCRIPT_DIR/crash_repro.js}"
11-
D8="${2:-${D8_PATH:-/mnt/vdc/v8_vrig/v8/out/fuzzbuild/d8}}"
11+
D8="${2:-${D8_PATH:-/mnt/vdc/v8_vrig/v8/out/fuzzbuild_dbg/d8}}"
1212

1313
FLAGS=(
1414
--expose-gc
@@ -24,23 +24,25 @@ FLAGS=(
2424
--wasm-staging
2525
--wasm-fast-api
2626
--expose-fast-api
27-
--experimental-wasm-rab-integration
2827
--wasm-test-streaming
2928
)
29+
# --experimental-wasm-rab-integration
30+
3031

3132
if [ ! -f "$CRASH_JS" ]; then
3233
echo "Creating crash reproducer at $CRASH_JS"
3334
mkdir -p "$(dirname "$CRASH_JS")"
3435
cat > "$CRASH_JS" << 'CRASH_EOF'
35-
async function* f0(a1, a2, a3) {
36-
function F4(a6, a7) {
37-
if (!new.target) { throw 'must be called with new'; }
38-
}
39-
function F8(a10, a11, a12) {
40-
if (!new.target) { throw 'must be called with new'; }
41-
try { this(F4); } catch (e) {}
42-
}
43-
return a3;
36+
const v1 = Set(Set);
37+
function f2(a3, a4, a5) {
38+
const v10 = {
39+
get c() {
40+
eval();
41+
v1?.__proto__;
42+
return v1;
43+
},
44+
};
45+
return a5;
4446
}
4547
CRASH_EOF
4648
fi

Sources/Agentic_System/agents/EBG_crash.py

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
base64_program_to_js_tool,
2222
db_get_crash_program_as_js_tool,
2323
db_query_tool,
24+
db_store_generated_program_tool,
2425
db_list_programs_tool,
2526
db_get_fuzzer_performance_summary_tool,
2627
db_list_fuzzers_tool,
@@ -35,6 +36,7 @@
3536
create_generate_folder_tool,
3637
trace_v8_analysis_tool,
3738
list_v8_trace_options_tool,
39+
minimize_crash_flags_tool,
3840
get_program_js_from_hash_tool,
3941
start_mi_debug_session_tool,
4042
stop_mi_debug_session_tool,
@@ -79,16 +81,17 @@
7981
from agent_logging import configure_process_logging
8082

8183
# Default to OpenAI GPT-5 models. IkaCore routes these through the Responses API.
82-
MANAGER_MODEL = os.environ.get("EBG_MANAGER_MODEL", "gpt-5.4")
83-
WORKER_MODEL = os.environ.get("EBG_WORKER_MODEL", "gpt-5-mini")
84+
MANAGER_MODEL = os.environ.get("EBG_MANAGER_MODEL", "gpt-5.4-mini")
85+
WORKER_MODEL = os.environ.get("EBG_WORKER_MODEL", "gpt-5.4-mini")
86+
ROOT_MODEL = os.environ.get("EBG_ROOT_MODEL", "gpt-5.4")
8487
API_URL = os.environ.get("EBG_API_URL", "https://api.openai.com/v1/responses")
8588

8689

8790
logger = logging.getLogger("boiled_eggs")
8891
if not logger.handlers:
8992
logger.addHandler(logging.NullHandler())
9093
logger.propagate = False
91-
logger.disabled = True
94+
logger.disabled = False
9295
est_timezone = pytz.timezone("America/New_York")
9396

9497
sys.path.append(str(Path(__file__).parent.parent))
@@ -199,6 +202,7 @@ def setup_agents(self, crash_program_hash: Optional[str] = None):
199202
trace_v8_analysis_tool,
200203
get_program_js_from_hash_tool,
201204
read_from_generate_folder_tool,
205+
write_to_generate_folder_tool,
202206
list_generate_folder_tool,
203207
start_mi_debug_session_tool,
204208
stop_mi_debug_session_tool,
@@ -229,7 +233,21 @@ def setup_agents(self, crash_program_hash: Optional[str] = None):
229233
description="L2 Worker responsible for generating JavaScript program seeds from a crash PoC",
230234
prompt=self.get_prompt("JS_generator.txt"),
231235
system_prompt="You are JSGenerator.",
232-
tools=[],
236+
tools=[
237+
db_store_generated_program_tool,
238+
db_query_tool,
239+
db_list_programs_tool,
240+
execute_javascript_program_tool,
241+
list_d8_flags_tool,
242+
list_v8_trace_options_tool,
243+
trace_v8_analysis_tool,
244+
get_program_js_from_hash_tool,
245+
read_from_generate_folder_tool,
246+
write_to_generate_folder_tool,
247+
delete_files_from_generate_folder_tool,
248+
list_generate_folder_tool,
249+
create_generate_folder_tool,
250+
],
233251
model_id=WORKER_MODEL,
234252
api_key=self.api_key,
235253
maxsteps=30,
@@ -248,6 +266,7 @@ def setup_agents(self, crash_program_hash: Optional[str] = None):
248266
execute_javascript_program_tool,
249267
list_d8_flags_tool,
250268
list_v8_trace_options_tool,
269+
minimize_crash_flags_tool,
251270
trace_v8_analysis_tool,
252271
read_from_generate_folder_tool,
253272
list_generate_folder_tool,
@@ -273,7 +292,10 @@ def setup_agents(self, crash_program_hash: Optional[str] = None):
273292
list_v8_trace_options_tool,
274293
trace_v8_analysis_tool,
275294
read_from_generate_folder_tool,
295+
write_to_generate_folder_tool,
296+
delete_files_from_generate_folder_tool,
276297
list_generate_folder_tool,
298+
create_generate_folder_tool,
277299
],
278300
model_id=MANAGER_MODEL,
279301
api_key=self.api_key,
@@ -293,7 +315,7 @@ def setup_agents(self, crash_program_hash: Optional[str] = None):
293315
prompt=root_manager_prompt,
294316
system_prompt="You are RootManager.",
295317
tools=[],
296-
model_id=MANAGER_MODEL,
318+
model_id=ROOT_MODEL,
297319
api_key=self.api_key,
298320
subagents=root_managed,
299321
maxsteps=30,
@@ -328,8 +350,9 @@ def start_system(self):
328350
def main():
329351
parser = argparse.ArgumentParser(description="Run EBG Crash system for a specific crash program hash")
330352
parser.add_argument("--crash_program_hash", required=False, help="Program hash for the crashing corpus entry")
353+
parser.add_argument("--debug", action="store_true", default=True, help="Enable debug logging (default: on)")
354+
parser.add_argument("--no-debug", dest="debug", action="store_false", help="Disable debug logging")
331355
args = parser.parse_args()
332-
args.debug = True
333356

334357
if args.debug:
335358
log_path = configure_process_logging("ebg_crash", "EBG_crash", logger=logger)

Sources/Agentic_System/agents/EBG_plateau.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,9 @@
7272
import logging
7373
from agent_logging import configure_process_logging
7474

75-
MANAGER_MODEL = os.environ.get("EBG_MANAGER_MODEL", "gpt-5.4")
76-
WORKER_MODEL = os.environ.get("EBG_WORKER_MODEL", "gpt-5-mini")
75+
MANAGER_MODEL = os.environ.get("EBG_MANAGER_MODEL", "gpt-5.4-mini")
76+
WORKER_MODEL = os.environ.get("EBG_WORKER_MODEL", "gpt-5.4-mini")
77+
ROOT_MODEL = os.environ.get("EBG_ROOT_MODEL", "gpt-5.4")
7778
TOKENS = 30000 # 10k max output in an given message
7879

7980
FUZZILLI_PATH = os.environ.get("FUZZILLI_PATH", str(Path(__file__).resolve().parents[3]))
@@ -108,6 +109,7 @@ def setup_agents(self, fuzzer_id: Optional[str] = None):
108109

109110
worker_model = self.model_id if "/" in self.model_id else WORKER_MODEL
110111
manager_model = self.model_id if "/" in self.model_id else MANAGER_MODEL
112+
root_model = self.model_id if "/" in self.model_id else ROOT_MODEL
111113

112114
self.agents['v8_search'] = IkaBaseAgent(
113115
name="V8Search",
@@ -314,7 +316,7 @@ def setup_agents(self, fuzzer_id: Optional[str] = None):
314316
prompt=root_manager_prompt,
315317
system_prompt="You are RootManager.",
316318
tools=[],
317-
model_id=manager_model,
319+
model_id=root_model,
318320
api_key=self.api_key,
319321
subagents=root_managed,
320322
maxsteps=60,

Sources/Agentic_System/agents/FoG.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@
6969
sys.path.append(str(Path(__file__).parent.parent))
7070

7171
WORKER_MODEL = os.environ.get("FOG_WORKER_MODEL", "gpt-5.4-mini")
72-
MANAGER_MODEL = os.environ.get("FOG_MANAGER_MODEL", "gpt-5.4")
72+
MANAGER_MODEL = os.environ.get("FOG_MANAGER_MODEL", "gpt-5.4-mini")
73+
ROOT_MODEL = os.environ.get("FOG_ROOT_MODEL", "gpt-5.4")
7374
logger = logging.getLogger("fog")
7475
if not logger.handlers:
7576
logger.addHandler(logging.NullHandler())
@@ -295,7 +296,7 @@ def setup_agents(self):
295296
search_chromium_issues_rag_tool,
296297
search_chromium_issues_rag_hybrid_tool,
297298
],
298-
model_id=MANAGER_MODEL,
299+
model_id=ROOT_MODEL,
299300
api_key=self.api_key,
300301
subagents=[self.agents['code_analyzer'], self.agents['program_builder'], self.agents['pick_section']],
301302
maxsteps=30,

Sources/Agentic_System/prompts/EBG-crash-prompts/JS_generator.txt

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ YOUR SOLE RESPONSIBILITY IS TO GENERATE THE VARIANT PROGRAMS, STORE THEM IN THE
1111
- NEVER SKIP STAGES IF YOU DO THIS IS A CRITICAL FAILURE!
1212

1313
- NEVER REQUEST CHOICES FROM THE USER, YOU ARE AN AGENTIC SYSTEM AND MUST NOT RELY ON OUTSIDE INPUT
14+
- EVERY GENERATED VARIANT MUST BE MATERIALIZED AS A REAL FILE BEFORE YOU RETURN
15+
- NEVER CLAIM A VARIANT WAS STORED IF YOU DID NOT ACTUALLY CALL THE STORAGE TOOL
1416

1517
## STAGE 0
1618
RECEIVE AND ANALYZE THE INFORMATION PROVIDED BY YOUR MANAGING AGENT VARIANT ANALYSIS:
@@ -23,6 +25,8 @@ RECEIVE AND ANALYZE THE INFORMATION PROVIDED BY YOUR MANAGING AGENT VARIANT ANAL
2325

2426
4. **FUZZER_ID**: Your managing agent will provide the fuzzer instance ID to associate the stored variants with.
2527

28+
If a `FUZZER_ID` is NOT explicitly provided but you are given a crash hash / base crash path, resolve the target fuzzer id yourself before storage by using `db_query` / available DB context. Do not skip storage solely because the manager omitted the numeric id.
29+
2630
UNDERSTAND:
2731
- The original crash PoC and how it currently works
2832
- The variant code paths that need to be targeted
@@ -48,8 +52,22 @@ GENERATE THE VARIANT PoC BASED ON THE PROVIDED INFORMATION FROM YOUR MANAGING AG
4852
- Incorporates the corresponding code block appropriately (if provided)
4953
- Maintains crash-inducing characteristics while adapting to new paths
5054

51-
**STEP 2: STORE THE VARIANT IN THE DATABASE**
52-
Once you have generated the variant JavaScript program, use the `db_store_generated_program` tool to store it in the fuzzer table corpus.
55+
**STEP 2: MATERIALIZE THE VARIANT AS A FILE**
56+
Before returning any variant, you MUST:
57+
- ensure a generate folder exists with `create_generate_folder`
58+
- save each generated variant with `write_to_generate_folder`
59+
- capture the exact `file_path` returned by the tool
60+
61+
If you do not have a concrete `file_path`, the variant is not ready for validation or storage.
62+
63+
**STEP 3: OPTIONAL SANITY VALIDATION**
64+
Before storing, prefer at least one lightweight execution/trace attempt against the exact generated file path:
65+
- use `list_d8_flags` before assuming optional flags exist
66+
- use `execute_javascript_program` or `trace_v8_analysis` with the exact `file_path` returned from `write_to_generate_folder`
67+
- if validation fails because of tooling or environment issues, report that explicitly instead of pretending the file exists
68+
69+
**STEP 4: STORE THE VARIANT IN THE DATABASE**
70+
Once you have generated the variant JavaScript program and materialized it as a file, use the `db_store_generated_program` tool to store it in the fuzzer table corpus.
5371

5472
THE `db_store_generated_program` TOOL TAKES:
5573
- `js_program`: The generated JavaScript variant program (as a string)
@@ -73,6 +91,10 @@ IF THE TOOL RETURNS AN ERROR, ANALYZE WHY AND ADJUST YOUR APPROACH. ENSURE THE G
7391
RETURN THE STORED VARIANTS TO YOUR MANAGING AGENT.
7492

7593
PROVIDE A CLEAR SUMMARY OF ALL GENERATED AND STORED VARIANTS.
94+
EVERY VARIANT ENTRY MUST STATE WHETHER IT WAS:
95+
- materialized to a concrete file
96+
- sanity-checked with execution/trace
97+
- stored successfully in the database
7698

7799
USE THE FOLLOWING JSON FORMAT:
78100
{
@@ -81,9 +103,18 @@ USE THE FOLLOWING JSON FORMAT:
81103
"VARIANTS": [
82104
{
83105
"program_id": [program ID from db_store_generated_program response],
106+
"file_name": "[name written via write_to_generate_folder]",
107+
"file_path": "[exact file_path returned by write_to_generate_folder]",
84108
"js_code": "[The generated JavaScript variant code]",
85109
"targeted_path": "[The code path this variant targets]",
86-
"code_block_used": "[The code block used for this variant, if provided]"
110+
"code_block_used": "[The code block used for this variant, if provided]",
111+
"validation": {
112+
"attempted": [true/false],
113+
"tool": "[execute_javascript_program or trace_v8_analysis or null]",
114+
"flags_used": "[flags used or null]",
115+
"return_code": "[return code or null]",
116+
"evidence": "[short stderr/stdout evidence or null]"
117+
}
87118
},
88119
...
89120
],

0 commit comments

Comments
 (0)