Repository navigation
Conversation
将 bash -c <path> 改为 bash <path>,消除命令注入向量; 增加属主/权限校验(lstat、符号链接跳过、group/other 可写检查)。 Log: 修复安全漏洞 CWE-78
mhduiy
marked this pull request as draft
October 30, 2026 04:47
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: mhduiy The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Reviewer's Guide本 PR 在不改变 autostop 调用接口和 Bash 执行行为的前提下,通过将路径作为脚本参数传递、跳过符号链接并校验文件属主与写权限,降低命令注入及脚本篡改风险,同时缓存配置路径以避免重复查询。 Sequence diagram for secure autostop script launchsequenceDiagram
participant SessionManager
participant FileSystem
participant Bash
SessionManager->>FileSystem: entryInfoList()
loop each autostop file
alt info.isSymLink()
SessionManager-->>SessionManager: [skip symlink]
else regular file
SessionManager->>FileSystem: lstat()
alt unsafe owner or permissions
SessionManager-->>SessionManager: [skip unsafe file]
else trusted file
SessionManager->>Bash: EXEC_COMMAND(/bin/bash, absoluteFilePath)
Bash-->>SessionManager: execute script file
end
end
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
修复内容
修复
SessionManager::launchAutostopScripts()中的 CWE-78 命令注入漏洞。修改内容
bash -c <path>改为bash <path>,文件路径作为脚本文件参数而非 shell 命令字符串传递info.isSymLink()检测并跳过符号链接,防止指向非预期文件getuid()),系统级目录文件属主须为 root(uid 0)S_IWGRP | S_IWOTH),防止其他用户篡改脚本内容lstat()代替stat():校验作用于链接本身,消除 TOCTOU 窗口QStandardPaths调用:提取到循环外,避免重复调用影响范围
launchAutostopScripts()方法体及新增#include <sys/stat.h>关联 Issue
DDE-517
Summary by Sourcery
Harden autostop script execution against command injection and unsafe script files.
Bug Fixes:
Enhancements: