Commit dc8eaa1
feat!: fix SSRF and XSS in OAuth consent form (breaking) (#748)
* feat!: remove user-supplied HA URL from OAuth flow (SSRF fix)
BREAKING CHANGE: OAuth mode now requires HOMEASSISTANT_URL as a
server-side environment variable. The consent form no longer accepts
a Home Assistant URL — only the Long-Lived Access Token is per-user.
This eliminates the SSRF vulnerability (GHSA-fmfg-9g7c-3vq7) where
an attacker could submit arbitrary URLs via the consent form to
perform internal network reconnaissance through error oracle responses.
Changes:
- Remove ha_url from OAuth tokens and consent form (Fix 1)
- Add warning box about token sharing with MCP client (Fix 2)
- Apply html.escape() to all user-controlled values in consent_form.py (Fix 3)
- Remove _validate_ha_credentials (no longer needed — token validated on first API call)
- Update OAuthProxyClient to use global HOMEASSISTANT_URL + per-user token
- Update docs/OAUTH.md with new setup instructions
- Update all OAuth unit tests
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* docs: add breaking change notice to OAuth guide
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* docs: fix uvx command syntax in OAuth guide
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* feat: show redirect_uri domain on consent form instead of client name/scopes
- Display the domain extracted from redirect_uri as the authorizing party
- Remove security-note footer (redundant with warning box)
- Return error if redirect_uri is missing from pending authorization
- Remove client_name and scopes params from create_consent_html (unused)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: address ruff lint errors and Gemini review comments
- Remove unused HomeAssistantOAuthProvider import (F401)
- Remove quotes from type annotations (UP037)
- Replace chr(10) with '\n' in f-string for readability
- Narrow except Exception to specific types in _extract_domain
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix(internal): quote HomeAssistantClient return annotation for TYPE_CHECKING guard
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>1 parent b703842 commit dc8eaa1
5 files changed
Lines changed: 293 additions & 421 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
6 | 8 | | |
7 | 9 | | |
8 | 10 | | |
| |||
36 | 38 | | |
37 | 39 | | |
38 | 40 | | |
| 41 | + | |
39 | 42 | | |
40 | 43 | | |
41 | 44 | | |
42 | 45 | | |
43 | 46 | | |
44 | 47 | | |
45 | 48 | | |
| 49 | + | |
46 | 50 | | |
47 | | - | |
| 51 | + | |
48 | 52 | | |
49 | 53 | | |
50 | 54 | | |
51 | 55 | | |
52 | 56 | | |
53 | 57 | | |
| 58 | + | |
54 | 59 | | |
55 | 60 | | |
56 | 61 | | |
57 | 62 | | |
| 63 | + | |
| 64 | + | |
58 | 65 | | |
59 | 66 | | |
60 | 67 | | |
61 | 68 | | |
62 | 69 | | |
63 | 70 | | |
64 | | - | |
65 | 71 | | |
66 | 72 | | |
67 | 73 | | |
| |||
80 | 86 | | |
81 | 87 | | |
82 | 88 | | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
| 89 | + | |
90 | 90 | | |
91 | 91 | | |
92 | | - | |
| 92 | + | |
93 | 93 | | |
94 | 94 | | |
| 95 | + | |
| 96 | + | |
95 | 97 | | |
96 | 98 | | |
97 | 99 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
23 | 22 | | |
24 | 23 | | |
25 | 24 | | |
| |||
32 | 31 | | |
33 | 32 | | |
34 | 33 | | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
35 | 37 | | |
36 | 38 | | |
37 | | - | |
38 | | - | |
| 39 | + | |
| 40 | + | |
39 | 41 | | |
40 | 42 | | |
41 | 43 | | |
| |||
52 | 54 | | |
53 | 55 | | |
54 | 56 | | |
55 | | - | |
| 57 | + | |
56 | 58 | | |
57 | 59 | | |
58 | | - | |
| 60 | + | |
59 | 61 | | |
60 | 62 | | |
61 | 63 | | |
62 | | - | |
63 | 64 | | |
64 | 65 | | |
65 | | - | |
66 | | - | |
| 66 | + | |
| 67 | + | |
67 | 68 | | |
68 | 69 | | |
69 | 70 | | |
70 | 71 | | |
71 | | - | |
| 72 | + | |
72 | 73 | | |
73 | 74 | | |
74 | | - | |
| 75 | + | |
75 | 76 | | |
76 | 77 | | |
77 | 78 | | |
| |||
610 | 611 | | |
611 | 612 | | |
612 | 613 | | |
613 | | - | |
614 | | - | |
615 | | - | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
616 | 617 | | |
617 | 618 | | |
| 619 | + | |
618 | 620 | | |
619 | 621 | | |
620 | 622 | | |
621 | 623 | | |
622 | 624 | | |
623 | | - | |
624 | | - | |
| 625 | + | |
| 626 | + | |
625 | 627 | | |
626 | 628 | | |
627 | 629 | | |
| |||
633 | 635 | | |
634 | 636 | | |
635 | 637 | | |
| 638 | + | |
636 | 639 | | |
| 640 | + | |
637 | 641 | | |
638 | | - | |
639 | | - | |
640 | | - | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
641 | 663 | | |
642 | 664 | | |
643 | 665 | | |
644 | | - | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
645 | 670 | | |
646 | 671 | | |
647 | | - | |
| 672 | + | |
648 | 673 | | |
649 | 674 | | |
650 | 675 | | |
| 676 | + | |
651 | 677 | | |
652 | 678 | | |
653 | 679 | | |
| |||
661 | 687 | | |
662 | 688 | | |
663 | 689 | | |
664 | | - | |
665 | | - | |
666 | | - | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
667 | 693 | | |
668 | 694 | | |
669 | 695 | | |
| |||
0 commit comments