Repository navigation
Require confirmation for code from /create/ links, and restrict credentialed CORS - #7806
Conversation
| .supports_credentials(), | ||
| // Any origin may call the API, but browsers send no cookies or HTTP auth. | ||
| // The API needs neither because clients set the `Authorization` header. | ||
| None => cors.allow_any_origin(), |
There was a problem hiding this comment.
missing / medium (docs, breaking-change gate): This changes the default (allowed_origins unset): browser clients on another origin that use credentials: 'include' (cookies or HTTP auth) now fail CORS. Please document it in three places:
- a
Behavior changeentry indocs.feldera.com/docs/changelog.md, next to the other entries under Unreleased helm-chart-reference.md:185, which still says "nullpermits all origins". Add: "without credentials; list origins to allow credentialed requests"- the
--allowed-originsdoc comment (config.rs:1315), which becomes the CLI help
|
Review: what I ran
I traced every save path for a way to save link code without the dialog. Ctrl+S, Accept Local, conflict auto-push, the leave-page dialog and Start all go through
Otherwise it looks good. The commits are clean and the PR includes tests. |
dbdd3b5 to
8972c2d
Compare
Without `allowed_origins`, the API accepted any origin and also allowed credentials. A page on another site could then send requests with the browser's cookies or HTTP auth. Credentialed CORS is now limited to the origins listed in `allowed_origins`. The any-origin default still lets clients call the API with an `Authorization` header, but no longer allows credentials. This came out of a pentest finding about cross-site requests through the web console. Signed-off-by: Karakatiza666 <bulakh.96@gmail.com>
A pentest found that opening a link like `/create/?name=...&program.sql=...&udf.rs=...` created and compiled a pipeline with the link's code on page load, so a third-party page could make the console compile code the user never saw. A /create/ link with code now creates an empty pipeline and opens the link's code as unsaved edits. While the pipeline holds code from a link, autosave is off and every save shows a "Compile code from a link?" dialog that lists the files. Confirming saves all unsaved files and restores the user's autosave setting. Links without code still open a demo by name. CodeEditor gets `autoSave` and `confirmSave` props, an `initialDraft` per file, and a single `saveAll` used by every save path. `saveFile` now resolves to whether the save happened, and declining the save from the unsaved-changes dialog keeps the user on the page. Signed-off-by: Karakatiza666 <bulakh.96@gmail.com>
Start, Start paused, Resume and Standby were disabled while the code had unsaved changes. They are now always enabled: they save the code first (which can show the pasted-link confirmation), wait for the in-flight PATCH requests, and then post the start. pipeline-manager starts the pipeline once the compilation ends. The compiling status `cause` 'upgrade' is renamed to 'start', meaning a start is scheduled after the compilation. Start stays enabled while the pipeline compiles with cause 'compile', and in error states when there are unsaved changes that may fix the error. "Cancel start" force-stops without a dialog, since the pipeline has not run yet, and the optimistic status keeps the compiling state. The grayed-out Start is a split button with a disabled chevron, so it keeps the layout of the enabled one. Signed-off-by: Karakatiza666 <bulakh.96@gmail.com>
8972c2d to
4cb009f
Compare
Fixes for a pentest finding: opening a
/create/?name=...&program.sql=...&udf.rs=...link created and compiled a pipeline with the link's code on page load. Any third-party page could make the console compile code the user never saw.Commits
allowed_origins, the API allowed any origin together with credentials. The any-origin default now no longer allows credentials. Clients that send anAuthorizationheader still work./create/link with code creates an empty pipeline and opens the link's code as unsaved edits. While the pipeline holds code from a link, autosave is off. Every save shows a "Compile code from a link?" dialog. Confirming saves all files. If the name is taken, the existing duplicate-name helper picks a-copyname. Links without code still open a demo by name.start. pipeline-manager starts the pipeline after compilation.cause'upgrade'is renamed to'start', meaning a start is scheduled.Testing
tests/pastedLink.e2e.tsandtests/startUnsavedChanges.e2e.ts.usePastedLink.spec.tsandpipelineManager.spec.ts.v0_preflight_from_any_origin_is_not_credentialed.Release note
When
allowedOrigins(--allowed-origins) is not set, cross-origin browser requests to the API no longer allow credentials (cookies, HTTP authentication). Requests with anAuthorizationheader still work. If a browser app on another origin usescredentials: 'include'orwithCredentials, or a cookie or Basic-auth proxy sits in front of Feldera, add that origin toallowedOrigins.