Repository navigation
Commit d5c69d3
committed
fix(webview): validate the webview-supplied view state id before adopting it
The stable view state id arrives over the webview postMessage channel, so the
declared string type is not a guarantee: a crafted message could carry a
non-string value (which the sanitizer would crash on), an unbounded string
(unbounded growth in the shared viewStates map), or an id another live view
already owns (adopting it would load that view's pinned profile, overlay and
mode here, and let this webview overwrite that view's persisted entry).
setViewStateId now rejects non-strings, bounds the key length, and refuses
ids claimed by another live instance; a refused view stays on its temporary
id and keeps working against the shared state. The specs gain an afterEach
that clears the static instance registry (the suites construct providers
directly and never dispose most of them), and the three shared-view handoff
tests now dispose the writer before the next view adopts the id - the
ownership rule the writer released the id under is exactly what those tests
assert, and the durable entry stays in storage across the handoff.
Proofs: ClineProvider.sticky-mode.spec 33/33 (3 new tests: non-string,
oversized, claimed-by-another-view), ClineProvider.spec 317/317,
webviewMessageHandler.spec 92/92; negative controls: disabling the ownership
check reddens exactly the claim test, widening the length bound reddens
exactly the oversized test, restores byte-exact (hash match);
eslint --max-warnings=0 clean; tsc clean except the two known local
telemetry-dist noise lines; prettier ALL-MATCHED on touched files.1 parent 67a9649 commit d5c69d3
3 files changed
Lines changed: 90 additions & 4 deletions
File tree
- src/core/webview
- __tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
259 | 259 | | |
260 | 260 | | |
261 | 261 | | |
| 262 | + | |
262 | 263 | | |
263 | 264 | | |
264 | 265 | | |
| |||
716 | 717 | | |
717 | 718 | | |
718 | 719 | | |
719 | | - | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
720 | 732 | | |
721 | 733 | | |
722 | 734 | | |
| |||
728 | 740 | | |
729 | 741 | | |
730 | 742 | | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
731 | 766 | | |
732 | 767 | | |
733 | 768 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
501 | 501 | | |
502 | 502 | | |
503 | 503 | | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
504 | 511 | | |
505 | 512 | | |
506 | 513 | | |
| |||
2275 | 2282 | | |
2276 | 2283 | | |
2277 | 2284 | | |
| 2285 | + | |
| 2286 | + | |
| 2287 | + | |
| 2288 | + | |
2278 | 2289 | | |
2279 | 2290 | | |
2280 | 2291 | | |
| |||
2287 | 2298 | | |
2288 | 2299 | | |
2289 | 2300 | | |
2290 | | - | |
2291 | 2301 | | |
2292 | 2302 | | |
2293 | 2303 | | |
| |||
2415 | 2425 | | |
2416 | 2426 | | |
2417 | 2427 | | |
| 2428 | + | |
| 2429 | + | |
| 2430 | + | |
| 2431 | + | |
2418 | 2432 | | |
2419 | 2433 | | |
2420 | 2434 | | |
| |||
2426 | 2440 | | |
2427 | 2441 | | |
2428 | 2442 | | |
2429 | | - | |
2430 | 2443 | | |
2431 | 2444 | | |
2432 | 2445 | | |
| |||
2765 | 2778 | | |
2766 | 2779 | | |
2767 | 2780 | | |
| 2781 | + | |
| 2782 | + | |
| 2783 | + | |
| 2784 | + | |
2768 | 2785 | | |
2769 | 2786 | | |
2770 | 2787 | | |
| |||
2777 | 2794 | | |
2778 | 2795 | | |
2779 | 2796 | | |
2780 | | - | |
2781 | 2797 | | |
2782 | 2798 | | |
2783 | 2799 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
121 | 121 | | |
122 | 122 | | |
123 | 123 | | |
| 124 | + | |
| 125 | + | |
124 | 126 | | |
125 | 127 | | |
126 | 128 | | |
| |||
1911 | 1913 | | |
1912 | 1914 | | |
1913 | 1915 | | |
| 1916 | + | |
| 1917 | + | |
| 1918 | + | |
| 1919 | + | |
| 1920 | + | |
| 1921 | + | |
| 1922 | + | |
| 1923 | + | |
| 1924 | + | |
| 1925 | + | |
| 1926 | + | |
| 1927 | + | |
| 1928 | + | |
| 1929 | + | |
| 1930 | + | |
| 1931 | + | |
| 1932 | + | |
| 1933 | + | |
| 1934 | + | |
| 1935 | + | |
| 1936 | + | |
| 1937 | + | |
| 1938 | + | |
| 1939 | + | |
| 1940 | + | |
| 1941 | + | |
| 1942 | + | |
| 1943 | + | |
| 1944 | + | |
| 1945 | + | |
| 1946 | + | |
| 1947 | + | |
| 1948 | + | |
1914 | 1949 | | |
0 commit comments