The vulnerability is an open redirect in Snipe-IT, caused by the application's unsafe handling of user redirection based on the HTTP Referer header. The core of the vulnerability lies in the App\Helpers\Helper::getRedirectOption function, which retrieves a URL from a session variable (back_url) and performs a redirect without validating that the URL is internal to the application. This allows an attacker to redirect users to malicious websites.
The vulnerability is triggered in a two-step process:
- Session Poisoning: An attacker tricks a user into clicking a link that directs them to an edit page within Snipe-IT (e.g., for an asset, accessory, or user). This request is crafted to have a malicious Referer header. The
edit methods in various controllers (e.g., AccessoriesController, AssetsController, UsersController) capture this Referer URL via url()->previous() and store it in the back_url session variable.
- Redirection: After the user submits a form on the edit page (e.g., by clicking 'Save'), the application calls the
App\Helpers\Helper::getRedirectOption function. If the user has selected to be redirected 'back', this function reads the poisoned URL from the session and uses redirect()->to() to redirect the user to the attacker's site.
The patch addresses this by replacing the unsafe redirect()->to() with Laravel's redirect()->intended(), which is designed to handle this type of redirection safely by ensuring the redirect target is a local URL. Additionally, the session key was changed from back_url to url.intended to align with Laravel's conventions.