Skip to content

fix: 修复安全漏洞并清理死代码#15

Open
PrintNow wants to merge 1 commit into
2.0from
fix/security-and-cleanup
Open

fix: 修复安全漏洞并清理死代码#15
PrintNow wants to merge 1 commit into
2.0from
fix/security-and-cleanup

Conversation

@PrintNow
Copy link
Copy Markdown
Owner

@PrintNow PrintNow commented May 4, 2026

Summary

  • 安全修复:修复 3 个安全漏洞
    • HandleActionController: 添加 is_subclass_of 校验,防止任意类实例化
    • RenderableController: 添加 LazyRenderable 接口校验,防止任意类实例化
    • TinymceController: 添加路径遍历防护和磁盘白名单校验
  • 代码清理:移除 Laravel 5.8 兼容死代码

变更文件

文件 变更
src/Http/Controllers/HandleActionController.php 添加 Action 类校验
src/Http/Controllers/RenderableController.php 添加 LazyRenderable 接口校验
src/Http/Controllers/TinymceController.php 添加路径遍历防护和磁盘验证
src/Repositories/EloquentRepository.php 移除 Laravel 5.8 兼容代码

安全详情

任意类实例化漏洞

风险:攻击者可通过 _actionrenderable 参数实例化服务器上的任意类,可能执行恶意代码。

修复

  • HandleActionController: 验证类必须继承 Dcat\Admin\Actions\Action
  • RenderableController: 验证类必须实现 Dcat\Admin\Contracts\LazyRenderable

路径遍历漏洞

风险:攻击者可通过 dir 参数访问服务器上的任意目录,通过 disk 参数访问任意存储磁盘。

修复

  • 移除路径遍历字符(../..\\..
  • 验证磁盘配置存在,不存在时回退到默认磁盘

Test plan

  • 验证 Action 类正常执行
  • 验证非法 Action 类被拒绝
  • 验证 LazyRenderable 正常加载
  • 验证非法 Renderable 类被拒绝
  • 验证 TinyMCE 文件上传功能正常
  • 验证路径遍历攻击被阻止
  • 验证 BelongsTo 关系保存功能正常

安全修复:
- HandleActionController: 添加 is_subclass_of 校验,防止任意类实例化
- RenderableController: 添加 LazyRenderable 接口校验,防止任意类实例化
- TinymceController: 添加路径遍历防护和磁盘白名单校验

代码清理:
- EloquentRepository: 移除 Laravel 5.8 兼容代码,直接使用 getForeignKeyName()
@PrintNow PrintNow force-pushed the fix/security-and-cleanup branch from 331ba40 to 46faf27 Compare May 19, 2026 05:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant