← PHP / Laravel · 目录

PHP-018 / 高级

SSRF:服务器请求用户指定的 URL

A10:2021 Server-Side Request Forgery · CWE-918 SSRF

为什么存在问题?

可访问内部网络,包括 169.254.169.254 元数据及 localhost 管理 API。

如何修复

php
$endpoint = config('integrations.endpoints')[$serviceId] ?? null;
abort_if($endpoint === null, 422);
Http::withoutRedirecting()->get($endpoint);

延伸阅读