antgroup / antgroup/YASA-Engine

求助帖

Open
#108 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
323
Forks
40
PR merge metrics
No merged PRs in 30d

Description

为复现SSRF漏洞,扫描langchain库v0.0.316版本langchain\libs\langchain\langchain\document_loaders文件夹,发现漏洞报告无法生成。指令如下。
./yasa-engine-linux-x64
--language python
--ruleConfigFile ./rules.json
--uastSDKPath ./uast4py
--checkerIds taint_flow_python_input
/mnt/d/GitHub_Projects/langchain/libs/langchain/langchain/document_loaders/

Image

开始排查问题时,ai建议用AUTO模式。于是修改指令如下:

./yasa-engine-linux-x64
--language python
--analyzer PythonAnalyzer
--uastSDKPath ./uast4py
--ruleConfigFile ./rules.json
--checkerIds taint_flow_python_input
--entrypointMode AUTO
--report ./report
/mnt/d/GitHub_Projects/langchain/libs/langchain/langchain/document_loaders/

报错结果不变。

为了锁定问题文件,我将大文件夹拆分进行分别扫描。拆分结构如下。

Image

最终锁定,问题出现在documenter文件夹中字母p开头的文件集合中。(即scan_3a_left,具体操作见下方)

我的指令如下:

拷贝基类(为了 SSRF 链路)

cp /mnt/d/GitHub_Projects/langchain/libs/langchain/langchain/document_loaders/{base.py,web_base.py,url.py} ./scan_part3a/

拷贝 P-R 开头的文件(到scan_part_3a文件夹)

cp /mnt/d/GitHub_Projects/langchain/libs/langchain/langchain/document_loaders/[p-r]* ./scan_part3a/
cd ~/yasa-bundle/
mkdir -p scan_3a_left scan_3a_right(拆分scan_part_3a文件夹)

依然保留基类

cp ./scan_part3a/{base.py,web_base.py,url.py} ./scan_3a_left/
cp ./scan_part3a/{base.py,web_base.py,url.py} ./scan_3a_right/

把 3a 里的文件按字母表前一半和后一半分发过去

cp ./scan_part3a/p* ./scan_3a_left/
cp ./scan_part3a/[q-r]* ./scan_3a_right/

扫左半部分

./yasa-engine-linux-x64 --language python --analyzer PythonAnalyzer --uastSDKPath ./uast4py --ruleConfigFile ./rules.json --checkerIds taint_flow_python_input --entrypointMode AUTO --report ./report_3a_left ./scan_3a_left/

扫右半部分

./yasa-engine-linux-x64 --language python --analyzer PythonAnalyzer --uastSDKPath ./uast4py --ruleConfigFile ./rules.json --checkerIds taint_flow_python_input --entrypointMode AUTO --report ./report_3a_right ./scan_3a_right/

右半部分没有问题,左半部分无法生成报告。报错如下:

Image

gemini怀疑: Yasa 引擎在处理 --report 参数时,如果你指定的是一个已经存在的目录(即 report_3a_left),它有时会因为尝试将其作为文件打开而报错,或者在拼接文件名时出现了逻辑混乱。
于是我删掉旧的目录,试着让引擎指向一个不存在的文件名,看能不能引起逻辑混乱问题。
rm -rf ./report_3a_left

./yasa-engine-linux-x64 --language python --analyzer PythonAnalyzer --uastSDKPath ./uast4py --ruleConfigFile ./rules.json --checkerIds taint_flow_python_input --entrypointMode AUTO --report ./report_3a_left_final.sarif ./scan_3a_left/

Image

显然, Yasa 引擎在处理 --report 参数时,会把指定参数作为存放report报告的文件夹,但是,打开该文件夹,并没有发现生成.sarif报告,仅生成诊断日志。不存在逻辑混乱问题。

Image

请问这个报错是什么问题导致的?AI怀疑是内存溢出,但是仅有四个漏洞,报告体量会有这么大吗?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the failure with YASA's PythonAnalyzer and the taint_flow_python_input checker on scan_3a_left, which contains base.py, web_base.py, url.py, and the p-prefixed document loader files. Compare the report-directory and .sarif-path runs, inspect the diagnostic log, and treat the issue as complete when the failure cause is identified and the scan produces the expected report.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
security, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.