跳转到正文
报告库
用途分类 / 其他用途

Laravel Specialist Skill 安全审计

作者说它能做什么(原文)

Build and configure Laravel 10+ applications, including creating Eloquent models and relationships, implementing Sanctum authentication, configuring Horizon queues, designing RESTful APIs with API resources, and building reactive interfaces with Livewire. Use when creating Laravel models, setting up queue workers, implementing Sanctum auth flows, building Livewire components, optimising Eloquent q

第三方安全检查结论

先别安装或运行

已检查文件
6
发现的风险
5
会不会运行危险命令?检查是否下载程序后直接运行、让他人远程控制电脑,或藏起要运行的命令。发现 1 项风险
中风险

验证步骤会从当前配置的队列执行一个真实任务

原文依据:3 处
发现了什么

Skill 把 queue:work --once 列为实现检查点;该命令不是只读检查,而是取出并处理一个排队任务。任务可能包含邮件、外部 API、发布、计费或数据库修改等应用特定副作用。

为什么需要注意

如果当前项目指向生产 Redis、SQS 或数据库队列,审查代码时可能提前执行真实业务任务,并改变数据或联系用户。

这是主动验证指令,不是只读状态检查:queue:work --once 会从当前配置的队列取出并执行一个任务。该 Skill 自己的任务模板会更新文章状态和发布时间,因此即使只运行一次也可能改变数据库;实际项目的任务还可能有其他副作用。风险只在代理执行该检查点且队列非空时发生。用户可限制该命令只能在隔离测试环境运行,或要求先确认连接、队列名称和待执行任务。

SKILL.md:250来自说明文档打开原文件
Run these at each workflow stage to confirm correctness before proceeding:| Stage | Command | Expected Result ||-------|---------|-----------------|| After migration | `php artisan migrate:status` | All migrations show `Ran` || After routing | `php artisan route:list --path=api` | New routes appear with correct verbs || After job dispatch | `php artisan queue:work --once` | Job processes without exception || After implementation | `php artisan test --coverage` | >85% coverage, 0 failures || Before PR | `./vendor/bin/pint --test` | PSR-12 linting passes |
查看另外 2 个位置
references/queues.md:268来自说明文档打开原文件
# Process one jobphp artisan queue:work --once
SKILL.md:199来自说明文档打开原文件
    public function handle(): void    {        $this->post->update([            'status'       => PostStatus::Published,            'published_at' => now(),        ]);    }
会不会泄露文件和密钥?检查是否发送含密码或密钥的文件,以及代码里是否直接写了密钥。发现 2 项风险
中风险

失败队列指南包含无确认或环境限制的全量清除命令

原文依据:2 处
发现了什么

参考文件提供 php artisan queue:flush,用于清空全部失败任务,但没有要求先列出、导出、备份或确认环境。失败任务记录通常是重试、故障分析和审计所需的数据。

为什么需要注意

若在错误环境执行,所有失败任务记录会被删除,用户可能无法重试重要工作,也会失去调查故障所需的上下文。

失败任务章节确实给出了 queue:flush,并明确标注为清空失败任务。该命令会删除当前应用失败任务存储中的全部记录,而周围没有环境限定、备份、列表或确认步骤;这些记录可能仍用于重试和故障调查。它只是参考代码块,不会因安装 Skill 自动执行,但代理在处理失败队列时可能采用。用户可禁止在生产环境运行,或要求执行前列出并导出失败任务。

references/queues.md:238来自说明文档打开原文件
// Retry all failed jobsphp artisan queue:retry all// Flush failed jobsphp artisan queue:flush// Prune failed jobsphp artisan queue:prune-failed --hours=48
查看另外 1 个位置
references/queues.md:232来自说明文档打开原文件
## Failed Jobs```php// Retry failed jobphp artisan queue:retry <job-id>// Retry all failed jobsphp artisan queue:retry all// Flush failed jobsphp artisan queue:flush// Prune failed jobsphp artisan queue:prune-failed --hours=48
中风险

队列错误模板可能把敏感异常内容写入持久日志

原文依据:3 处
发现了什么

模板记录完整异常消息,监控示例还把异常对象本身交给日志系统。异常可能包含请求内容、数据库值、远程响应、连接信息或令牌;模板没有清理、分级或限制这些字段。

为什么需要注意

敏感数据可能进入应用日志及外部日志平台,扩大可访问人员、保留期限和泄露范围。

两个可复用模板都把异常信息写入日志:一个记录完整 getMessage(),监控示例还记录异常对象。若异常包含请求数据、数据库内容、远程响应或连接信息,这些内容可能进入持久日志并被日志读者或外部日志服务看到。源码没有证明这些秘密一定存在或日志一定外传,但泄露路径合理。用户可要求作者展示字段白名单、脱敏和按环境控制详细异常的做法。

SKILL.md:207来自说明文档打开原文件
    public function failed(\Throwable $e): void    {        // Log or notify — never silently swallow failures        logger()->error('PublishPost failed', ['post' => $this->post->id, 'error' => $e->getMessage()]);    }
查看另外 2 个位置
references/queues.md:355来自说明文档打开原文件
    Queue::failing(function (JobFailed $event) {        // Called when job fails        \Log::error('Job failed', [            'job' => $event->job->resolveName(),            'exception' => $event->exception,        ]);    });
references/queues.md:40来自说明文档打开原文件
    public function failed(\Throwable $exception): void    {        // Handle job failure        \Log::error('Post processing failed', [            'post_id' => $this->post->id,            'error' => $exception->getMessage(),        ]);    }
会不会删除文件或一直在后台运行?检查是否大范围删除文件、改写磁盘,或设置自动启动。未发现风险
会不会绕过安全保护?检查是否跳过网站安全验证、开放过多文件权限,或取消操作前的确认。发现 2 项风险
高风险

API 模板允许任意已登录用户更新或删除其他人的文章

原文依据:3 处
发现了什么

路由只要求 Sanctum 登录;控制器的 update 和 destroy 直接操作路由绑定的 Post,没有调用策略、Gate 或所有权检查。这与参考测试所期待的“不能修改他人文章”不一致。

为什么需要注意

如果直接采用模板,任何拥有普通账号的人都可能修改或删除其能猜到或获得 ID 的文章,造成内容篡改或数据丢失。

API 示例仅用 Sanctum 验证登录身份,却把路由绑定的任意 Post 直接交给 update 和 destroy;控制器中没有策略、Gate 或所有权检查。若用户把这些“起始模板”直接用于应用,任何已登录且能猜到文章标识的用户都可能修改或删除他人的文章。测试指南虽要求他人更新返回 403,但示例控制器本身没有实现该要求。用户可要求作者在每个写操作中明确展示 Policy/Gate 授权。

references/routing.md:52来自说明文档打开原文件
    // Protected routes    Route::middleware('auth:sanctum')->group(function () {        Route::post('/posts', [PostController::class, 'store']);        Route::put('/posts/{post}', [PostController::class, 'update']);        Route::delete('/posts/{post}', [PostController::class, 'destroy']);    });});
查看另外 2 个位置
references/routing.md:104来自说明文档打开原文件
    public function update(UpdatePostRequest $request, Post $post)    {        $post->update($request->validated());        return new PostResource($post);    }    public function destroy(Post $post)    {        $post->delete();        return response()->noContent();    }}
references/testing.md:94来自说明文档打开原文件
    public function test_user_cannot_update_others_post(): void    {        $user = User::factory()->create();        $otherUser = User::factory()->create();        $post = Post::factory()->create(['user_id' => $otherUser->id]);        $response = $this->actingAs($user)->put("/api/posts/{$post->id}", [            'title' => 'Updated Title',        ]);        $response->assertStatus(403);    }
高风险

Livewire 模板暴露缺少对象级授权的编辑和删除操作

原文依据:5 处
发现了什么

表单可接收任意 Post 并在 save 中直接更新;另一个公开组件方法按客户端提供的 ID 查找并删除文章。两个操作均未在执行时调用 authorize。Livewire 公共方法和属性可由浏览器请求触发,不能把客户端参数视为可信。

为什么需要注意

采用这些模板后,能够访问组件的用户可能替换文章参数或 ID,从而修改、关联标签、上传图片到或删除不属于自己的记录。

Livewire 表单接受路由提供的 Post,并在 save 中直接更新;删除方法也按浏览器提供的 ID 查找并删除,二者都没有对象级授权。文件后面另有正确调用 authorize 的独立示例,但它不会自动保护前面的组件。因此,若这些片段被直接采用,能够触发组件方法的用户可能编辑或删除无权管理的文章。用户可要求作者把授权检查合并进每个可变更数据的完整模板,并测试越权 ID。

references/livewire.md:141来自说明文档打开原文件
    public function mount(?Post $post = null): void    {        if ($post) {            $this->post = $post;            $this->title = $post->title;            $this->content = $post->content;            $this->tags = $post->tags->pluck('id')->toArray();        }    }
查看另外 4 个位置
references/livewire.md:156来自说明文档打开原文件
    public function save(): void    {        $validated = $this->validate();        if ($this->post) {            $this->post->update($validated);            $message = 'Post updated successfully!';        } else {            $this->post = Post::create($validated);            $message = 'Post created successfully!';        }        if ($this->image) {            $this->post->update([                'image_path' => $this->image->store('posts', 'public'),            ]);        }        $this->post->tags()->sync($this->tags);
references/livewire.md:305来自说明文档打开原文件
// Emit eventclass PostList extends Component{    public function deletePost($postId): void    {        Post::find($postId)->delete();        $this->emit('postDeleted', $postId);    }}
references/livewire.md:307来自说明文档打开原文件
{    public function deletePost($postId): void    {        Post::find($postId)->delete();        $this->emit('postDeleted', $postId);    }}
references/livewire.md:464来自说明文档打开原文件
    public function mount(Post $post): void    {        $this->authorize('update', $post);        $this->post = $post;    }    public function save(): void    {        $this->authorize('update', $this->post);        // Save logic
会不会误导 AI 或隐藏内容?检查工作说明是否要求 AI 忽略你的指令、干扰检查结果,或夹带看不见的文字。未发现风险
会不会偷偷改推广链接或收款方?检查是否强制替换推广链接或收款对象,同时要求隐瞒更改。未发现风险

Skill 逻辑拆解

6 个说明模块

该 Skill 的主要工作方式是生成 Laravel 应用代码,并要求运行 Artisan 命令检查迁移、路由和测试。命令会作用于当前 Laravel 项目所配置的环境。

查看原文
SKILL.md:22来自说明文档打开原文件
1. **Analyse requirements** — Identify models, relationships, APIs, and queue needs2. **Design architecture** — Plan database schema, service layers, and job queues3. **Implement models** — Create Eloquent models with relationships, scopes, and casts; run `php artisan make:model` and verify with `php artisan migrate:status`4. **Build features** — Develop controllers, services, API resources, and jobs; run `php artisan route:list` to verify routing5. **Test thoroughly** — Write feature and unit tests; run `php artisan test` before considering any step complete (target >85% coverage)

主文件要求将所给代码模板作为每次实现的起点;因此参考文件中的授权、删除、日志和队列示例可能被直接带入用户项目,而不只是供阅读。

查看原文
SKILL.md:62来自说明文档打开原文件
## Code TemplatesUse these as starting points for every implementation.

Skill 明文要求验证输入、不明文保存敏感数据并编写权限相关测试,表明其声明目标包含基本安全控制;但部分实际模板没有一致落实这些目标。

查看原文
SKILL.md:52来自说明文档打开原文件
### MUST NOT DO- Use raw queries without protection (SQL injection)- Skip eager loading (causes N+1 problems)- Store sensitive data unencrypted- Mix business logic in controllers- Hardcode configuration values- Skip validation on user input- Use deprecated Laravel features
references/testing.md:94来自说明文档打开原文件
    public function test_user_cannot_update_others_post(): void    {        $user = User::factory()->create();        $otherUser = User::factory()->create();        $post = Post::factory()->create(['user_id' => $otherUser->id]);        $response = $this->actingAs($user)->put("/api/posts/{$post->id}", [            'title' => 'Updated Title',        ]);        $response->assertStatus(403);    }
从这里开始 · 工作说明SKILL.md
laravel-specialist
连线表示工作说明包含的模块,不是实际运行顺序。点击模块可查看原文。

文件引用关系图

5 处引用
哪些文件发起引用引用了什么
连线表示真实的文件引用,不是运行顺序。点击节点可高亮相关连线,并查看具体文件和原文位置。虚线表示还有文件需要定位。
文件与检查记录6 个文件

检查范围与遗漏

逐文件查看涉及的内容

下方列出本次涉及的原文范围;纳入检查不代表已查清所有问题。

  • SKILL.md已纳入全文
  • references/eloquent.md已纳入全文
  • references/livewire.md已纳入全文
  • references/queues.md已纳入全文
  • references/routing.md已纳入全文
  • references/testing.md已纳入全文

这份报告只针对上方版本。我们看了拿到的代码和说明文件,没有实际运行 Skill,也没有检查它另外安装的软件包。因此,这不是“保证安全”的承诺;换了版本或使用环境,结果也可能不同。

  • SKILL.md工作说明
  • references/eloquent.md配套文件
  • references/livewire.md配套文件
  • references/queues.md配套文件
  • references/routing.md配套文件
  • references/testing.md配套文件

代码和说明中提到的操作

连接外部网站
SKILL.md:6来自说明文档打开原文件
metadata:  author: https://github.com/Jeffallan  version: "1.1.0"
SKILL.md:264来自说明文档打开原文件
[Documentation](https://jeffallan.github.io/claude-skills/skills/backend/laravel-specialist/)
references/routing.md:356来自说明文档打开原文件
    'allowed_methods' => ['*'],    'allowed_origins' => ['http://localhost:3000'],    'allowed_headers' => ['*'],
运行命令
references/queues.md:261来自说明文档打开原文件
```bash# Start worker
references/routing.md:321来自说明文档打开原文件
```bash# Generate route cache
references/testing.md:483来自说明文档打开原文件
```bash# Run all tests
读取密钥或账号配置
references/routing.md:360来自说明文档打开原文件
    'max_age' => 0,    'supports_credentials' => true,];
读取了多少行
2,440
文件校验值(用于核对版本)
bdbf24e14d77e5ed4cb1ae8395fb4b5e6446061b7ff2684bdb38ce81b1c085bd