Skip to content

Harden sessions, headers and scans; run shared jobs once across instances - #103

Merged
sudoitir merged 7 commits into
mainfrom
security/harden-sessions-headers-jobs
Sep 28, 2026
Merged

sudoitir merged 7 commits into
mainfrom
security/harden-sessions-headers-jobs

Conversation

@sudoitir

Copy link
Copy Markdown
Owner

Implements the harden-sessions-headers-jobs OpenSpec change.

Security

  • CSRF: only a request a valid API bearer token authenticated skips CSRF. Any other Authorization header is answered with 401. Before, a junk header plus the session cookie skipped the check.
  • Sessions: sessions are really stored in JDBC now. The Boot 4 spring-boot-starter-session-jdbc module was missing, so they were held in memory. Disabling a user, removing a grant or changing a role's permissions ends the affected users' sessions (ADR-0123).
  • CSP: every response carries a Content-Security-Policy (script-src 'self' 'wasm-unsafe-eval', frame-ancestors 'none', …), and every plugin SVG is sandboxed (ADR-0122). The plugin-template e2e now fails on any CSP refusal.
  • Dependencies: embedded Tomcat raised to 11.0.25 (three critical CVEs in 11.0.24); dev tooling patched (adm-zip, the docs site's Vite).
  • CI: CodeQL and OSV-Scanner workflows (ADR-0124).

Jobs (breaking for plugins)

ScheduledJob declares Scope.INSTANCE or Scope.INSTALLATION. Installation-wide jobs run on one instance per tick through ShedLock (ADR-0125). Plugin contract 4.

Verification

  • ./mvnw verify green locally (1328 tests); web build and lint green. One web test was flaky under load; it passes on its own, 3 of 3.
  • The plugin-template e2e was run locally against the built jar: install, update, roll back and purge, with no CSP refusals. A signed-in sweep of the main screens and Swagger UI found no CSP refusals.
  • OSV-Scanner reports no issues across all four manifests.

🤖 Generated with Claude Code

Mahdi Amirabdollahi and others added 6 commits September 28, 2026 15:09
…request

A request that carried any Authorization header skipped the CSRF check,
even when the header authenticated nothing. Next to a signed-in browser's
session cookie, a junk header (Basic, an unknown bearer token, anything)
let a state-changing request through without a CSRF token.

An Authorization header that is not a valid API bearer token is now
refused with 401, and only a request a bearer token authenticated skips
CSRF. API clients that send a valid token see no change; a client that
sent a stale or malformed header alongside a session must drop it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Disabling a user, removing a grant from them, or changing a role's
permissions now signs out every affected user at once. Their next
request answers 401. Before, a session kept the grants it had at
sign-in until it timed out, up to 8 hours.

Sessions are also stored in the database again. Spring Boot 4 moved
session auto-configuration into its own module, which was missing, so
sessions were held in memory: lost on restart and not shared between
instances. Studio now uses spring-boot-starter-session-jdbc and the
existing spring_session tables. The session cookie is now named
SESSION instead of JSESSIONID, so everyone signs in again once after
upgrading.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…assets

Every response now carries a Content-Security-Policy. Scripts,
connections and workers must come from Studio's own origin, plugins
(object/embed) are refused, and no page may frame Studio. If an injection
bug ever let markup through, it could neither load a script from
elsewhere nor send data out.

Every SVG a plugin serves is now sandboxed, as its icon already was, so
an SVG opened directly renders inert instead of running as Studio.

Plugin UIs are unaffected when they bundle what they load, as the plugin
guide asks. A UI that pulled scripts, fonts or data from another origin
must bundle them instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Spring Boot 4.1 still manages Tomcat 11.0.24, which carries three
critical vulnerabilities (GHSA-9xv2-5v5q-p794, GHSA-gcx9-497g-6cp6,
GHSA-h3x4-894j-xpx5). Studio now runs 11.0.25. The plugin template
compiles against the same version.

Development tooling is patched too: adm-zip, used by the module
federation build, is raised to 0.6.1, and the documentation site builds
on Vite 6.4.3. Neither ships in the image.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Adds both workflows and ADR-0124. OSV-Scanner fails a pull request that
adds a known vulnerability and fails main and the weekly run on any.
CodeQL (security-extended) reports to code scanning.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When several Studio instances share one database, every instance used to
run every background job, so housekeeping, reapers, sweeps and partition
maintenance ran once per instance. Jobs whose work is on shared state
now run on one instance per tick, through ShedLock on Studio's database
(a new shedlock table): preview housekeeping, the event, request-reply
and metric reapers, the request-reply deadline sweep, partition
maintenance, scrape tier C and topology discovery. A crashed instance
frees its jobs within a minute or one interval. The job status API
reports each job's scope and when another instance last ran it; a tick
another instance ran never makes a job look stalled.

BREAKING CHANGE: the plugin contract is now 4. Every ScheduledJob states
a scope: ScheduledJob.fixedDelay(id, featureId, Scope.INSTALLATION or
Scope.INSTANCE, interval, task), and the same for cron. Use INSTALLATION
for work on shared rows and INSTANCE for this instance's own state
(a cache, a buffer). Rebuild plugins against this release with
studio.contract 4; Studio refuses plugins built for contract 3.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-advanced-security

Copy link
Copy Markdown

You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool.

What Enabling Code Scanning Means:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

GitHub refuses results from an advanced CodeQL workflow while the
repository's default setup is enabled, and default setup already
analyses Java, TypeScript, Actions and Python on every pull request.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sudoitir
sudoitir merged commit 05b73f6 into main Sep 28, 2026
19 checks passed
@sudoitir
sudoitir deleted the security/harden-sessions-headers-jobs branch September 28, 2026 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants