Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions reviews/cosai-ws4-issue158/attack_vectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,15 @@

sys.path.insert(0, r"D:\doubao\ls-proto\prototypes\openai-agent-trust-runtime\src")

from ls_agent_trust import TrustRuntime, TrustViolation # noqa: E402
from ls_agent_trust.openai_demo import bounded_authority # noqa: E402
try:
from ls_agent_trust import TrustRuntime, TrustViolation # noqa: E402
from ls_agent_trust.openai_demo import bounded_authority # noqa: E402
_HAVE_TRUST = True
_IMP_ERR = None
except ImportError as _err:
# 外部依赖缺失时优雅跳过,而非抛出回溯使 CI 误红(red-team finding P1)
_HAVE_TRUST = False
_IMP_ERR = _err


def scenario(name: str, fn) -> dict:
Expand Down Expand Up @@ -48,6 +55,10 @@ def completed_dispatch(runtime, child, scope):


def main() -> None:
if not _HAVE_TRUST:
print("SKIP attack_vectors: 缺少外部依赖 ls_agent_trust (%s)。" % _IMP_ERR)
print(" 安装 LS Agent Trust Runtime(openai-agent-trust-runtime)后方可运行本独立评审脚本。")
sys.exit(2)
results: list[dict] = []

# --- Attack scenario 1: submit as an agent other than the dispatched child ---
Expand Down
55 changes: 39 additions & 16 deletions reviews/verified-transition-loop/make_variants.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,47 @@
#!/usr/bin/env python
# make_variants.py — build adversarial variants of the VTL transparency-log fixture.
# Inputs: transparency-log-v0.14.json (prototype fixture). Outputs: _variant_A/B.json.
# Usage: python make_variants.py <fixture.json> <outdir>
import json, copy, sys, os
# Usage: python make_variants.py <fixture.json> [outdir]
import json
import copy
import sys
import os
import argparse

fix = json.load(open(sys.argv[1], encoding="utf-8"))
outdir = sys.argv[2] if len(sys.argv) > 2 else "."
os.makedirs(outdir, exist_ok=True)

A = copy.deepcopy(fix)
A["base_bundle"].pop("inclusion_path", None) # evidence missing
def main() -> int:
ap = argparse.ArgumentParser(
description="构建 VTL transparency-log fixture 的对抗变体(缺 inclusion / 篡改 entry)。")
ap.add_argument("fixture", help="transparency-log-*.json 输入路径")
ap.add_argument("outdir", nargs="?", default=".", help="输出目录(默认当前目录)")
args = ap.parse_args()

B = copy.deepcopy(fix)
d = bytearray(B["base_bundle"]["entry"]["snapshot_digest"], "ascii")
d[0] = ord("0") if d[0] != ord("0") else ord("1") # evidence tampered
B["base_bundle"]["entry"]["snapshot_digest"] = d.decode()
try:
with open(args.fixture, encoding="utf-8") as fh:
fix = json.load(fh)
except (OSError, ValueError) as e:
print("ERROR: 无法读取 fixture %s: %s" % (args.fixture, e), file=sys.stderr)
return 2

for name, obj in [("_variant_A_missing_inclusion.json", A), ("_variant_B_tampered_entry.json", B)]:
with open(os.path.join(outdir, name), "w", encoding="utf-8") as f:
json.dump(obj, f, ensure_ascii=False, separators=(",", ":"))
print("wrote", name)
outdir = args.outdir
os.makedirs(outdir, exist_ok=True)

print("run: node reference/transparency-log-strict-v0.14.mjs <out>/<variant> [now_ms]")
A = copy.deepcopy(fix)
A["base_bundle"].pop("inclusion_path", None) # evidence missing

B = copy.deepcopy(fix)
d = bytearray(B["base_bundle"]["entry"]["snapshot_digest"], "ascii")
d[0] = ord("0") if d[0] != ord("0") else ord("1") # evidence tampered
B["base_bundle"]["entry"]["snapshot_digest"] = d.decode()

for name, obj in [("_variant_A_missing_inclusion.json", A), ("_variant_B_tampered_entry.json", B)]:
with open(os.path.join(outdir, name), "w", encoding="utf-8") as f:
json.dump(obj, f, ensure_ascii=False, separators=(",", ":"))
print("wrote", name)

print("run: node reference/transparency-log-strict-v0.14.mjs <out>/<variant> [now_ms]")
return 0


if __name__ == "__main__":
sys.exit(main())
Loading