Repository navigation
Commit 668b2dd
authored
fix(cli): secure Prisma Studio's local HTTP server (#29890)
## Linked issue
Private vulnerability report submitted through GitHub PVR.
## Summary
Prisma Studio advertised a localhost URL while its HTTP server listened
on every interface and returned wildcard CORS headers. Because `POST
/bff` executes database queries, a reachable network client—or a
malicious website visited while Studio was open—could read or modify the
connected database.
This change binds the Node, Bun, and Deno servers explicitly to
`127.0.0.1`, rejects browser requests whose `Origin` is not the active
`localhost` or `127.0.0.1` Studio URL before routing, and removes
wildcard CORS responses. Origin-less local tooling remains supported.
## Root cause
The Studio rewrite introduced for Prisma 7.0.0 treated the advertised
`http://localhost` URL as if it also constrained the listener. It did
not specify a host and enabled permissive CORS around a privileged SQL
BFF. The later pre-bundled server refactor preserved both behaviors.
## Testing performed
- Dependency-aware CLI build passed across 39 workspace projects.
- Targeted ESLint passed for the affected source and test files.
- Studio request-handler tests passed (20/20).
- Studio listener tests passed (5/5).
- Full CLI Vitest passed all Studio/security coverage; one unrelated
existing `Init.vitest.ts` fixture failed.
- Manual built-CLI test confirmed only `127.0.0.1` was listening, the
host LAN address refused connections, same-origin SQL succeeded, and
hostile-origin SQL returned 403 before execution.
- Headed browser smoke test loaded Studio with no console warnings or
errors.
## Skill update
n/a — security hardening only; no user-facing CLI command, flag, API,
config field, error code, or terminology changed.
## Checklist
- [x] All commits are signed off (`git commit -s`) per the DCO.
- [x] I read `CONTRIBUTING.md` and the change is scoped to one logical
concern.
- [x] Tests are updated.
- [ ] The PR title uses a Linear ticket prefix — n/a, this work comes
from a private vulnerability report rather than a Linear issue.
- [x] The **Skill update** section is filled in.
## Notes for the reviewer
The server and BFF are implemented in the maintained `v7` branch of
`prisma/prisma`; `studio-core` supplies the bundled frontend and does
not own this HTTP trust boundary.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **Security**
* Studio servers now bind exclusively to the local loopback address.
* Requests from unauthorized origins, including cross-origin preflight
requests, return `403 Forbidden`.
* Permissive cross-origin access and related response headers have been
removed.
* **Bug Fixes**
* Improved protection for Studio backend and telemetry endpoints.
* Standardized local server behavior across supported runtimes.
* Same-origin requests continue to work correctly.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Signed-off-by: Søren Bramer Schmidt <sorenbs@gmail.com>1 parent e312a9c commit 668b2dd
5 files changed
Lines changed: 275 additions & 57 deletions
File tree
- packages/cli/src
- __tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
| 81 | + | |
81 | 82 | | |
82 | 83 | | |
83 | 84 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| |||
278 | 278 | | |
279 | 279 | | |
280 | 280 | | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
281 | 290 | | |
282 | 291 | | |
283 | 292 | | |
| |||
308 | 317 | | |
309 | 318 | | |
310 | 319 | | |
| 320 | + | |
311 | 321 | | |
312 | 322 | | |
313 | 323 | | |
314 | 324 | | |
| 325 | + | |
315 | 326 | | |
316 | 327 | | |
317 | 328 | | |
318 | 329 | | |
319 | | - | |
320 | | - | |
321 | 330 | | |
322 | 331 | | |
323 | 332 | | |
| |||
345 | 354 | | |
346 | 355 | | |
347 | 356 | | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
348 | 369 | | |
349 | 370 | | |
350 | 371 | | |
| |||
474 | 495 | | |
475 | 496 | | |
476 | 497 | | |
| 498 | + | |
477 | 499 | | |
478 | 500 | | |
479 | 501 | | |
480 | 502 | | |
481 | 503 | | |
482 | 504 | | |
| 505 | + | |
483 | 506 | | |
484 | 507 | | |
485 | 508 | | |
486 | 509 | | |
487 | 510 | | |
488 | 511 | | |
489 | | - | |
490 | | - | |
491 | | - | |
492 | | - | |
| 512 | + | |
| 513 | + | |
493 | 514 | | |
494 | 515 | | |
| 516 | + | |
| 517 | + | |
495 | 518 | | |
496 | 519 | | |
497 | 520 | | |
| |||
630 | 653 | | |
631 | 654 | | |
632 | 655 | | |
633 | | - | |
634 | | - | |
635 | | - | |
636 | | - | |
637 | | - | |
638 | | - | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
639 | 660 | | |
640 | 661 | | |
641 | 662 | | |
| |||
676 | 697 | | |
677 | 698 | | |
678 | 699 | | |
679 | | - | |
| 700 | + | |
680 | 701 | | |
681 | 702 | | |
682 | 703 | | |
683 | | - | |
| 704 | + | |
684 | 705 | | |
685 | 706 | | |
686 | | - | |
687 | | - | |
688 | | - | |
689 | | - | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
690 | 711 | | |
691 | 712 | | |
692 | 713 | | |
693 | | - | |
694 | | - | |
695 | | - | |
696 | | - | |
697 | | - | |
698 | | - | |
699 | | - | |
700 | | - | |
| 714 | + | |
| 715 | + | |
701 | 716 | | |
702 | | - | |
703 | | - | |
704 | | - | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
705 | 720 | | |
706 | | - | |
707 | | - | |
708 | | - | |
709 | | - | |
710 | | - | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
711 | 731 | | |
0 commit comments