+ "details": "## Summary\n\nAn Open Redirect vulnerability exists in Taguette that allows attackers to craft malicious URLs that redirect users to arbitrary external websites after authentication. This can be exploited for phishing attacks where victims believe they are interacting with a trusted Taguette instance but are redirected to a malicious site designed to steal credentials or deliver malware.\n\n**Severity:** Medium to High \n\n---\n\n## Details\n\nThe application accepts a user-controlled `next` parameter and uses it directly in HTTP redirects without any validation. The vulnerable code is located in two places:\n\n### Location 1: Login Handler (`taguette/web/views.py`, lines 140-144)\n\n```python\ndef _go_to_next(self):\n next_ = self.get_argument('next', '')\n if not next_:\n next_ = self.reverse_url('index')\n return self.redirect(next_) # ← No validation of next_ parameter\n```\n\nThis method is called after successful login (line 132) and when an already-logged-in user visits the login page (line 109).\n\n### Location 2: Cookies Prompt Handler (`taguette/web/views.py`, lines 79-85)\n\n```python\ndef post(self):\n self.set_cookie('cookies_accepted', 'yes', dont_check=True)\n next_ = self.get_argument('next', '')\n if not next_:\n next_ = self.reverse_url('index')\n return self.redirect(next_) # ← No validation of next_ parameter\n```\n\nIn both cases, if `next_` is provided by the user, it is passed directly to `self.redirect()` without checking whether it points to the same host or is a relative URL.\n\n---\n\n[](url)\n\n\n## PoC\n\nSimply replace `[your-taguette-instance]` with your Taguette server domain and test these URLs in your browser:\n\n### Test 1: Cookies Prompt Redirect\n\n```\nhttps://[your-taguette-instance]/cookies?next=https://google.com\n```\n\n1. Open the URL above in your browser\n2. Click \"Accept cookies\" button\n3. **Result:** You are redirected to `https://google.com` (external site)\n\n### Test 2: Login Redirect\n\n```\nhttps://[your-taguette-instance]/login?next=https://google.com\n```\n\n1. Open the URL above in your browser\n2. Log in with valid credentials\n3. **Result:** You are redirected to `https://google.com` (external site)\n\n### Test 3: Already Logged In Redirect\n\n```\nhttps://[your-taguette-instance]/login?next=https://google.com\n```\n\n1. First, log in to Taguette normally\n2. Then open the URL above\n3. **Result:** You are immediately redirected to `https://google.com`\n\n> **Note:** We use `google.com` as a safe external site for testing. In a real attack, this would be a phishing site.\n\n---\n\n## Impact\n\n- **Who is affected:** All users of any Taguette instance running in multi-user mode\n- **Attack vector:** Social engineering / phishing via crafted URLs\n- **Exploitability:** Trivial - requires only crafting a URL with a malicious `next` parameter\n- **Consequences:**\n - Credential theft through phishing\n - Malware distribution\n - Session hijacking\n - Reputation damage to organizations running Taguette instances\n\nThe vulnerability is particularly dangerous because:\n1. The login page displayed is completely legitimate, building victim trust\n2. Users have just entered their credentials, making them more likely to enter them again on a fake \"session expired\" page\n3. The trusted domain in the URL makes the attack more convincing\n\n---\n\n## Recommended Fix\n\nValidate that the `next` parameter is either a relative URL or points to the same host before redirecting.\n\n### Example Fix\n\nAdd a validation function:\n\n```python\nfrom urllib.parse import urlparse\n\ndef is_safe_url(url, host):\n \"\"\"Check if URL is safe for redirect (relative or same host).\"\"\"\n if not url:\n return False\n parsed = urlparse(url)\n # Reject protocol-relative URLs (//evil.com)\n if url.startswith('//'):\n return False\n # Allow relative URLs (no scheme and no netloc)\n if not parsed.scheme and not parsed.netloc:\n return True\n # Allow same-host URLs\n return parsed.netloc == host\n```\n\nThen update the vulnerable methods:\n\n```python\ndef _go_to_next(self):\n next_ = self.get_argument('next', '')\n if not next_ or not is_safe_url(next_, self.request.host):\n next_ = self.reverse_url('index')\n return self.redirect(next_)\n```\n\nApply the same fix to the `CookiesPrompt.post()` method.\n\n---",
0 commit comments