- 필수 기능
- 시작하기
- Glossary
- 표준 속성
- Guides
- Agent
- 통합
- 개방형텔레메트리
- 개발자
- Administrator's Guide
- API
- Datadog Mobile App
- CoScreen
- Cloudcraft
- 앱 내
- 서비스 관리
- 인프라스트럭처
- 애플리케이션 성능
- APM
- Continuous Profiler
- 스팬 시각화
- 데이터 스트림 모니터링
- 데이터 작업 모니터링
- 디지털 경험
- 소프트웨어 제공
- 보안
- AI Observability
- 로그 관리
- 관리
ID: php-security/symfony-arbitrary-redirect
Language: PHP
Severity: Error
Category: Security
CWE: 601
This rule is designed to prevent potential security vulnerabilities, such as Open Redirect attacks, where an attacker can manipulate the redirection URL and lead users to malicious websites. Open Redirect attacks can lead to phishing attacks, stealing users’ credentials, or spreading malware.
Unsanitized user inputs can contain malicious code or URLs, which, when used in a redirect function, can compromise the security of the application and its users. If the application redirects users based on unsanitized user inputs, it could potentially redirect users to harmful websites or expose sensitive user information.
To comply with this rule, developers should always sanitize and validate user inputs before using them in a redirect function. Also, developers can restrict the redirect URLs to a list of known safe URLs or use relative paths. This way, even if a user input is used in a redirect function, the application ensures that the redirection leads to a safe and intended location.
<?php
class Controller
{
public function foo(): RedirectResponse
{
$bar = $session->get('bar');
return $this->redirect($bar);
}
public function baz(): RedirectResponse
{
$addr = $request->query->get('item');
return $this->redirect('https://'. $addr);
}
}
<?php
class Controller
{
public function foo(): RedirectResponse
{
$bar = $session->get('bar');
if ($bar === 'bar') {
return $this->redirect('bar');
}
}
public function baz(): RedirectResponse
{
$addr = $request->query->get('item');
if (item === 'item')
return $this->redirect('https://domain.tld/item');
}
}