This repository was archived by the owner on Oct 10, 2025. It is now read-only.
Commit d064a2f
authored
fix: do not redirect to invalid redirectTo on error to (#664)
If an attacker requests an invalid redirectTo the service correctly
validates the value and throws on error. However, in the case of the
/verify endpoint we redirect to the very same redirectTo that we just
invalidated indicating the redirectTo was invalid.
### **PR Type**
Bug fix
___
### **Description**
- Fix redirect URL validation in ticket verification
- Prevent redirection to invalid/malicious URLs on error
- Use client URL instead of invalid redirectTo parameter
- Add test case for wrong redirect URL scenario
___
### Diagram Walkthrough
```mermaid
flowchart LR
A["Invalid redirectTo"] --> B["Validation Error"]
B --> C["Use ClientURL instead"]
C --> D["Safe Redirect"]
```
<details> <summary><h3> File Walkthrough</h3></summary>
<table><thead><tr><th></th><th align="left">Relevant
files</th></tr></thead><tbody><tr><td><strong>Bug
fix</strong></td><td><table>
<tr>
<td>
<details>
<summary><strong>verify_ticket.go</strong><dd><code>Fix redirect URL
validation error handling</code>
</dd></summary>
<hr>
go/controller/verify_ticket.go
<ul><li>Replace invalid <code>redirectTo</code> with
<code>ctrl.config.ClientURL</code> on validation <br>error<br> <li>
Prevent potential security vulnerability from malicious redirect
URLs</ul>
</details>
</td>
<td><a
href="https://github.com/nhost/hasura-auth/pull/664/files#diff-7a36d63db0b247e393d4e7a9a2ff52be673c33aa2a4e40af06f1a4445edb3c32">+1/-1</a>
</td>
</tr>
</table></td></tr><tr><td><strong>Tests</strong></td><td><table>
<tr>
<td>
<details>
<summary><strong>verify_ticket_test.go</strong><dd><code>Add test for
invalid redirect URL handling</code>
</dd></summary>
<hr>
go/controller/verify_ticket_test.go
<ul><li>Add test case for "wrong redirect URL" scenario<br> <li> Verify
proper error handling with malicious redirect URL<br> <li> Test expected
redirect to client URL with appropriate error message</ul>
</details>
</td>
<td><a
href="https://github.com/nhost/hasura-auth/pull/664/files#diff-0c15b83d87b39bbbb4175ee401fef063bd686677d110c89822ddc287c5f0e57e">+31/-0</a>
</td>
</tr>
</table></td></tr></tr></tbody></table>
</details>
___1 parent c618a7a commit d064a2f
2 files changed
Lines changed: 32 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
112 | | - | |
| 112 | + | |
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
526 | 526 | | |
527 | 527 | | |
528 | 528 | | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
529 | 560 | | |
530 | 561 | | |
531 | 562 | | |
| |||
0 commit comments