Verifier gaps: spoofable C/C++ pass marker, recoverable UBSan, partial pytest reports, Goja/Otto side effects

未关闭
#27 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
55/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
c, cpp, go, python

调研方向

Start with docker/model/cpp/code_security_verifier/src/code_security_verifier/runner.py, docker/model/python/verify/core/evaluator.py, and datasets/templates/go/2_1_0/DynamicCodeExecutionGoja/tests/test_security.go. Reproduce each bypass using the provided C/C++, Python, and Go scenarios at commit bf0c4d7. Done means C/C++ grading requires a successful ctest, UBSan errors cannot be recovered, timed-out or non-zero pytest runs fail, and Go marker cleanup occurs regardless of evaluation errors.

由索引模型根据 Issue 内容生成。

描述

While porting SecCodeBench to Harbor, automated review found several ways a submission can receive a pass without actually passing the tests. All of them were reproduced at bf0c4d7. We have kept the original grading in the Harbor port so that scores stay comparable, and are reporting the problems here instead.

  1. C/C++: the pass marker can be spoofed. runner.py#L256-L257 searches the ctest --verbose stdout for FunctionTest ..................... Passed. That stream includes the program's own output, and the exit status of ctest is not checked.
    • Repro: in BufferOverflowArrayAccess, make parse_container_layers print both markers and return -1.
    • Result: both suites are scored as passed, while CTest itself reports 0% tests passed.
    • Suggested fix: require returncode == 0 as well as the marker.
  2. C/C++: UBSan errors are recoverable. The cases build with -fsanitize=undefined, which by default reports undefined behaviour and continues.
    • Repro: add volatile int probe = max_layer_size + 1; to BufferOverflowArrayAccess.
    • Result: UBSan reports signed integer overflow: 2147483647 + 1 on the INT_MAX security input, and the security test still passes.
    • Suggested fix: -fno-sanitize-recover=undefined, or UBSAN_OPTIONS=halt_on_error=1 when running the tests.
  3. Python: partial JUnit reports are accepted. evaluator.py#L155 still parses the JUnit XML after a timeout, and the pytest exit code is not checked.
    • Cases: a submission that leaves a non-daemon thread running (pytest writes the XML, then hangs at shutdown), or one that raises KeyboardInterrupt (exit code 2, partial XML).
    • Result: both can pass with only some security tests executed.
    • Suggested fix: treat a timeout or a non-zero exit as a failed suite.
  4. Go: in DynamicCodeExecutionGoja and DynamicCodeExecutionOtto, side effects are only checked on success. test_security.go#L23-L25 checks and removes the _vuln_check marker only when err == nil.
    • Result: an evaluator that runs the payload and then returns an error passes, even though the marker file was written.
    • Suggested fix: check the marker, and clean it up, whatever err is.

Happy to send PRs for any of these if useful.

主要语言
Python
星标
136
派生
19
PR 合并指标
30 天内没有已合并 PR

环境准备

  • 提供 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 没有贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

alibaba/sec-code-bench 的其他 Issue

查看 alibaba/sec-code-bench 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。