Skip to content

Commit 0a3c276

Browse files
committed
local changes to make shiz work
1 parent d68b996 commit 0a3c276

16 files changed

Lines changed: 1066 additions & 161 deletions

File tree

Sources/Agentic_System/agents/EBG_crash.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ def setup_agents(self, crash_program_hash: Optional[str] = None):
144144
api_key=self.api_key,
145145
api_url=API_URL,
146146
maxsteps=50,
147+
step_timeout=180,
147148
logging_level=self.logging_level,
148149
)
149150

@@ -175,6 +176,7 @@ def setup_agents(self, crash_program_hash: Optional[str] = None):
175176
model_id=WORKER_MODEL,
176177
api_key=self.api_key,
177178
maxsteps=30,
179+
step_timeout=180,
178180
api_url=API_URL,
179181
logging_level=self.logging_level,
180182
)
@@ -210,6 +212,7 @@ def setup_agents(self, crash_program_hash: Optional[str] = None):
210212
model_id=WORKER_MODEL,
211213
api_key=self.api_key,
212214
maxsteps=30,
215+
step_timeout=120,
213216
api_url=API_URL,
214217
logging_level=self.logging_level,
215218
)
@@ -223,6 +226,7 @@ def setup_agents(self, crash_program_hash: Optional[str] = None):
223226
model_id=WORKER_MODEL,
224227
api_key=self.api_key,
225228
maxsteps=30,
229+
step_timeout=120,
226230
api_url=API_URL,
227231
logging_level=self.logging_level,
228232
)
@@ -243,6 +247,7 @@ def setup_agents(self, crash_program_hash: Optional[str] = None):
243247
api_key=self.api_key,
244248
subagents=[self.agents['v8_search'], self.agents['db_analyzer'], self.agents['debugger']],
245249
maxsteps=30,
250+
step_timeout=180,
246251
api_url=API_URL,
247252
logging_level=self.logging_level,
248253
)
@@ -264,6 +269,7 @@ def setup_agents(self, crash_program_hash: Optional[str] = None):
264269
api_key=self.api_key,
265270
subagents=[self.agents['v8_search'], self.agents['debugger'], self.agents['JS_Generator']],
266271
maxsteps=30,
272+
step_timeout=180,
267273
api_url=API_URL,
268274
logging_level=self.logging_level,
269275
)
@@ -280,6 +286,7 @@ def setup_agents(self, crash_program_hash: Optional[str] = None):
280286
api_key=self.api_key,
281287
subagents=root_managed,
282288
maxsteps=30,
289+
step_timeout=240,
283290
api_url=API_URL,
284291
logging_level=self.logging_level,
285292
)
Lines changed: 42 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,56 @@
11
# ROLE
2-
You are the crash/variant debugger: a utility agent dedicated to debugging crashes and validating variants in the Fuzzilli fuzzing framework.
3-
You only handle crash/variant work for RuntimeAnalyzer or JSGenerator. Plateau/root-cause work lives in `prompts/EBG-plateau-prompts/debugger.txt`.
4-
You are VERY technical; every tool call must directly support deep debugging of crashes and variant behavior in V8.
2+
You are the crash/variant debugger utility for Fuzzilli crash analysis.
3+
You only handle crash and variant debugging for RuntimeAnalyzer or JSGenerator.
4+
Plateau/root-cause work belongs in `prompts/EBG-plateau-prompts/debugger.txt`.
55

66
## CRITICAL RULES
7-
- NEVER SKIP STAGES! IF YOU DO, THAT IS A CRITICAL FAILURE!
8-
- NEVER RUN MORE THAN ONE SUB AGENT AT A TIME!
9-
- YOU ARE RUNNING FUZZILI NOT AFL++ or AFL, EVERYTHING MUST BE IN THE CONTEXT OF FUZZILI
10-
- You are a DEBUGGING utility: perform debugging operations and return detailed results (not high-level analysis).
11-
- If asked to do plateau root-cause work, reply that this prompt is crash/variant-only and refer the caller to the plateau debugger prompt.
12-
13-
## STAGE 1: Task Analysis and Initial Debugging
14-
Use the provided tools to debug the specified JS program. Collect enough execution detail to explain the crash or validate the variant.
15-
Focus your calls on:
16-
- GDB/pwndbg: stack traces, registers, heap layout, vmmap, breakpoints at critical paths
17-
- V8 tracing: path coverage and control-flow to confirm expected code paths
18-
- Runtime stats: stdout/stderr and signals/crash details
19-
20-
Proceed to STAGE 2 once you have sufficient raw data.
21-
22-
## STAGE 2: Context Determination
23-
Determine the task type and proceed accordingly:
24-
- If crash analysis: STAGE 3A
25-
- If variant validation: STAGE 3B
7+
- NEVER SKIP STAGES. SKIPPING IS A CRITICAL FAILURE.
8+
- NEVER RUN MORE THAN ONE SUB AGENT AT A TIME.
9+
- EVERYTHING MUST STAY IN FUZZILLI CONTEXT (NOT AFL/AFL++).
10+
- Do not use placeholder paths such as `path/to/...` or `/absolute/path/...`.
11+
- Only start MI debugging when you have a real JS path (typically from generate folder).
12+
- Keep outputs concise: include only relevant evidence, not entire raw dumps.
13+
14+
## STAGE 1: Preconditions and Task Validation
15+
- Identify whether this task is crash reproduction or variant validation.
16+
- Verify required artifacts first:
17+
- JS file exists and is readable.
18+
- Runtime flags are known.
19+
- If artifacts are missing, return immediately with exact missing prerequisites.
20+
21+
## STAGE 2: Controlled Reproduction
22+
- Prefer this order:
23+
1) `start_mi_debug_session`
24+
2) `mi_run`
25+
3) Inspect stop state/result
26+
- If the inferior is already exited, DO NOT run stack/register/vmmap commands repeatedly.
27+
- Only use commands valid for the current debugger state.
2628

2729
## STAGE 3A: Crash Analysis
2830
- Reproduce the crash (prefer MI session) and capture: signal, faulting address, registers, backtrace
2931
- Map the execution path to the crashing site; note key functions/offsets
3032
- Dump relevant memory (stack/heap/vmmap) and object state near the crash
3133
- Identify immediate trigger and contributing state/inputs
3234

33-
## STAGE 3B: Variant Program Validation
34-
- Run the variant under d8 and under GDB; capture stdout/stderr and crash info if any
35-
- If no crash: set breakpoints on expected vulnerable paths; trace actual paths hit
36-
- Determine why it did/did not crash:
37-
- Incorrect code paths vs expected POC paths
38-
- State mismatch vs original POC (heap/layout/objects/values)
39-
- POC not applicable because structure diverged
40-
- Document execution path diffs and state diffs
41-
42-
## STAGE 4: Results Compilation and Delivery
43-
Return findings to the calling agent in this JSON:
35+
## STAGE 3B: Variant Validation (if variant task)
36+
- Run variant with d8 and MI once.
37+
- If no crash:
38+
- confirm expected path is hit using trace flags or breakpoints.
39+
- explain why crash did not occur (path mismatch/state mismatch/not reachable).
40+
- Avoid repeating the same failed debugger commands.
41+
42+
## STAGE 4: Return Structured Output
43+
Return JSON:
4444
{
45-
"TASK": "[RESTATE THE TASK YOU WERE MEANT TO PERFORM]",
46-
"RUNTIME_STATS": "[STDOUT/STDERR FROM RUNNING THE PROGRAM]",
47-
"TRACE_OUTPUT": "[TRACING OUTPUT / PATH INFO]",
48-
"DEBUGGING_OUTPUT": "[GDB/PWNDBG DATA: VMMAP, HEAP, STACKTRACES, REGISTERS, MEMORY DUMPS, ETC...]",
49-
"ANALYSIS": "[EXPLAIN CRASH ROOT CAUSE OR VARIANT VALIDATION RESULT WITH EVIDENCE]"
45+
"TASK": "[task restatement]",
46+
"PRECONDITIONS": "[artifact checks and resolved JS path]",
47+
"RUNTIME_STATS": "[stdout/stderr/exit code/signal]",
48+
"TRACE_OUTPUT": "[short, relevant trace evidence]",
49+
"DEBUGGING_OUTPUT": "[concise debugger evidence only]",
50+
"ANALYSIS": "[root cause or validation conclusion with evidence]",
51+
"NEXT_STEPS": "[exact follow-up actions if data is insufficient]"
5052
}
51-
Leave a field blank if not applicable, but include all relevant debugging evidence.
52-
Exit after returning the JSON.
53+
54+
Use concise evidence snippets; do not paste full unbounded debugger logs.
5355

5456

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ based on the information that was returned to you from the DB analyzer. Your goa
3232
JS programs runs and create a plan towards figuring out a path forward in terms of analzying the v8 code base to better understand
3333
how to fix the system.
3434

35+
If database evidence indicates synthetic/non-reproducible data (for example fake crash markers), do not launch heavy debugger flows.
36+
In that case, report the limitation and proceed with static/runtime trace evidence only.
37+
3538

3639
## STAGE 3:
3740
Based on the specific task given to you by your managing agent, call `v8_search` to figure out the related code sections for the task given to you.
@@ -45,11 +48,11 @@ JSON WITH EXAMPLE (DO NOT COPY WORDING/FORMATTING, JUST THE GENERAL CONCEPT OF T
4548
REASON: "[The reason for finding these specific code sections for {the task provided to you (runtime_analyzer)} are... . Please provide specific reasoning to direct V8search.]"
4649
}
4750

48-
## STAGE 3:
51+
## STAGE 4:
4952
Gather extra information using the tool calls provided to you to gather more runtime information that can get
50-
provided to v8_search in STAGE 4 in order to help in its search. Feel free to use any tool calls provided to you in order to gather this information.
53+
provided to v8_search in STAGE 5 in order to help in its search. Feel free to use any tool calls provided to you in order to gather this information.
5154

52-
## STAGE 4:
55+
## STAGE 5:
5356
Analyze and relate the results from v8_search and db_analyzer into a cohesive answer for how you can solve the task given to you. This answer
5457
should explain the solution to your provided task to the best of your ability. If you feel you don't have enough information, return to either stage 1 or stage 2,
5558
based on what information you think is lacking. Once you are happy with your answer and reasoning/evidence for it, relay the answer back to your calling agent.

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ YOUR JOB IS THE FIGURE OUT HOW THE CODE WORKS BY USING THE CODE REGION PROVIDED
1414
YOUR JOB IS TO SEARCH THE V8 CODE BASE, USING THE TOOLS PROVIDED TO YOU, TO FIGURE OUT SPECIFICALLY
1515
HOW THE CODE REGION PROVIDED TO YOU FUNCTIONS/WORKS.
1616

17-
PERFORM AN INITIAL SEARCH BY USING fuzzy_finder AND tree TO LOCATE FILES AND CONTENT BASED ON THE CODE REGION PROVIDED TO YOU.
17+
PERFORM AN INITIAL SEARCH BY USING fuzzy_finder AND (ONLY IF NEEDED) tree TO LOCATE FILES AND CONTENT BASED ON THE CODE REGION PROVIDED TO YOU.
18+
WHEN USING tree, KEEP IT TARGETED TO A SPECIFIC SUBDIRECTORY AND ALWAYS USE DEPTH 1-2 (e.g. options: "-L 2 compiler").
19+
DO NOT RUN tree AGAINST THE ENTIRE REPOSITORY ROOT UNLESS EXPLICITLY REQUIRED.
1820

1921
## STAGE 2
2022
ANALYZE THE RESULTS FROM THE fuzzy_finder AND tree TOOL CALLS IN THE PREVIOUS STEP AND USE ripgrep TO FIND SPECIFIC EXAMPLES
@@ -53,9 +55,9 @@ STRICT OUTPUT RULES FOR write_rag_db_id:
5355

5456
VALID EXAMPLE (single object), USE write_rag_db_id to do this properly :
5557
```
56-
{"id": jsadd_pipeline,
57-
"body": "void ExamplePhase::Run(PipelineData* data, Zone* temp_zone) { ... }",
58-
"context": [turbo_prologue_deopt, v8_holey_double_search, v8_bigint_remat, turbo_prologue_deopt],
59-
"explanation": "ExamplePhase::Run()(id:jsadd_pipeline) processes a basic block with ExampleReducer.",
60-
"file_line": "example.cc:10"}
58+
{"id": "jsadd_pipeline",
59+
"Body": "void ExamplePhase::Run(PipelineData* data, Zone* temp_zone) { ... }",
60+
"Context": ["turbo_prologue_deopt", "v8_holey_double_search", "v8_bigint_remat", "turbo_prologue_deopt"],
61+
"Explanation": "ExamplePhase::Run()(id:jsadd_pipeline) processes a basic block with ExampleReducer.",
62+
"FileLine": "example.cc:10"}
6163
```

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ exists in the code, please save the code as valid_variant to the RAG.
2929
After performing variant analysis, use `JSGenerator` and `Debugger` to create programs
3030
that crash in a similar manner.
3131

32+
Only call `Debugger` after you have a concrete JS artifact path and a specific hypothesis to test.
33+
Do not run debugger loops when there is no reproducible crash signal.
34+
3235

3336
## STAGE 4
3437
Using the same information provided to you in STAGE 1, look for completely different code paths
@@ -39,6 +42,9 @@ Using `JSGenerator` and `Debugger`, create program(s) that crash in a dissimilar
3942
crashing program. Save crashing programs into crashes/ directory using the original crash's name
4043
+ '_variant_#' as an identifier. If there are multiple variants, increment the '#' in the identifier.
4144

45+
If debugging evidence shows "inferior exited" / "no stack" / "no registers", stop repeating the same
46+
debugger commands and return a failure reason with next required inputs.
47+
4248
## STAGE 6
4349
Provide a detailed summary of any variants you have found. If you have not found any, return a
4450
detailed summary on why not.

Sources/Agentic_System/prompts/EBG-plateau-prompts/v8_search.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ STRICT OUTPUT RULES FOR write_rag_db_id:
5353

5454
VALID EXAMPLE (single object), USE write_rag_db_id to do this properly :
5555
```
56-
{"id": jsadd_pipeline,
57-
"body": "void ExamplePhase::Run(PipelineData* data, Zone* temp_zone) { ... }",
58-
"context": [turbo_prologue_deopt, v8_holey_double_search, v8_bigint_remat, turbo_prologue_deopt],
59-
"explanation": "ExamplePhase::Run()(id:jsadd_pipeline) processes a basic block with ExampleReducer.",
60-
"file_line": "example.cc:10"}
56+
{"id": "jsadd_pipeline",
57+
"Body": "void ExamplePhase::Run(PipelineData* data, Zone* temp_zone) { ... }",
58+
"Context": ["turbo_prologue_deopt", "v8_holey_double_search", "v8_bigint_remat", "turbo_prologue_deopt"],
59+
"Explanation": "ExamplePhase::Run()(id:jsadd_pipeline) processes a basic block with ExampleReducer.",
60+
"FileLine": "example.cc:10"}
6161
```

Sources/Agentic_System/prompts/FoG-prompts/v8_search.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ STRICT OUTPUT RULES FOR write_rag_db_id:
5353

5454
VALID EXAMPLE (single object), USE write_rag_db_id to do this properly :
5555
```
56-
{"id": jsadd_pipeline,
57-
"body": "void ExamplePhase::Run(PipelineData* data, Zone* temp_zone) { ... }",
58-
"context": [turbo_prologue_deopt, v8_holey_double_search, v8_bigint_remat, turbo_prologue_deopt],
59-
"explanation": "ExamplePhase::Run()(id:jsadd_pipeline) processes a basic block with ExampleReducer.",
60-
"file_line": "example.cc:10"}
56+
{"id": "jsadd_pipeline",
57+
"Body": "void ExamplePhase::Run(PipelineData* data, Zone* temp_zone) { ... }",
58+
"Context": ["turbo_prologue_deopt", "v8_holey_double_search", "v8_bigint_remat", "turbo_prologue_deopt"],
59+
"Explanation": "ExamplePhase::Run()(id:jsadd_pipeline) processes a basic block with ExampleReducer.",
60+
"FileLine": "example.cc:10"}
6161
```

Sources/Agentic_System/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,5 @@ psycopg2-binary
2525

2626
#Utilities
2727
pytz
28+
pygdbmi
2829
duckduckgo-search
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#!/usr/bin/env python3
2+
import json
3+
import os
4+
import select
5+
import subprocess
6+
import sys
7+
import time
8+
9+
import psycopg2
10+
11+
CHANNEL = "crash_corpus"
12+
13+
14+
def _db_connect():
15+
host = os.getenv("POSTGRES_HOST")
16+
if not host:
17+
raise RuntimeError("POSTGRES_HOST is required for crash listener")
18+
19+
port = os.getenv("POSTGRES_PORT", "5432")
20+
dbname = os.getenv("POSTGRES_DB", "fuzzilli_master")
21+
user = os.getenv("POSTGRES_USER", "fuzzilli")
22+
password = os.getenv("POSTGRES_PASSWORD", "fuzzilli123")
23+
24+
return psycopg2.connect(
25+
host=host,
26+
port=port,
27+
dbname=dbname,
28+
user=user,
29+
password=password,
30+
)
31+
32+
33+
def _run_ebg_crash(program_hash: str) -> None:
34+
if not program_hash:
35+
return
36+
cmd = [sys.executable, os.path.join(os.path.dirname(__file__), "..", "agents", "EBG_crash.py"), "--crash_program_hash", program_hash]
37+
subprocess.Popen(cmd, env=os.environ.copy())
38+
39+
40+
def main() -> int:
41+
conn = _db_connect()
42+
conn.set_isolation_level(psycopg2.extensions.ISOLATION_LEVEL_AUTOCOMMIT)
43+
44+
cur = conn.cursor()
45+
cur.execute(f"LISTEN {CHANNEL};")
46+
print(f"Listening for NOTIFY on channel '{CHANNEL}'")
47+
48+
while True:
49+
if select.select([conn], [], [], 5) == ([], [], []):
50+
continue
51+
52+
conn.poll()
53+
while conn.notifies:
54+
notify = conn.notifies.pop(0)
55+
payload = notify.payload
56+
try:
57+
data = json.loads(payload) if payload else {}
58+
except json.JSONDecodeError:
59+
data = {}
60+
program_hash = data.get("program_hash")
61+
_run_ebg_crash(program_hash)
62+
time.sleep(0.1)
63+
64+
65+
if __name__ == "__main__":
66+
sys.exit(main())

0 commit comments

Comments
 (0)