Skip to content

Fix XSS vulnerability, modernize build, and fix API deprecations#138

Open
mbSmaga wants to merge 5 commits intojenkinsci:masterfrom
mbSmaga:fix/security-2811-xss
Open

Fix XSS vulnerability, modernize build, and fix API deprecations#138
mbSmaga wants to merge 5 commits intojenkinsci:masterfrom
mbSmaga:fix/security-2811-xss

Conversation

@mbSmaga
Copy link
Copy Markdown

@mbSmaga mbSmaga commented Apr 3, 2026

Summary

  • Fix stored XSS vulnerability in Docker Swarm Dashboard (SECURITY-2811): Escape all user-controlled values (node.name, node.role, build.fullDisplayName, task.service.Spec.Name, queue item fields) using <j:out> in Jelly templates. Add getSafeId() to SwarmNode for XSS-safe DOM element IDs. Sanitize JSON chart data output to prevent </script> injection.
  • Modernize POM to build on Java 11+: Bump jenkins.version to 2.462.3, update bom to 3435.v238d66a_043fb_, replace deprecated java.level with maven.compiler.release, and remove obsolete findbugs / animal-sniffer configurations.
  • Fix Docker API 1.44 deprecation: Move Networks from ServiceSpec to TaskTemplate to align with the current Docker Swarm API.
  • Add volume option and improve help for cache dir: Add a new volumeDir config field on DockerSwarmAgentTemplate for persistent named volumes, and add inline help descriptions for both cacheDir and volumeDir.
  • Use default JNLP command when no custom command is configured: When unixCommand is empty, fall back to the standard JNLP agent launch command instead of sending an empty command array to Docker.

Test plan

  • Deploy the HPI to a Jenkins instance with Docker Swarm Cloud configured
  • Verify the Swarm Dashboard renders without XSS (check node names, queue items, chart data with special characters)
  • Verify builds are scheduled and agents connect successfully
  • Verify the volume and cache dir configuration fields appear in the agent template config
  • Verify the plugin builds cleanly with mvn verify on Java 11+

mbSmaga added 5 commits April 3, 2026 20:23
Escape Docker API response values rendered in dashboard Jelly templates
to prevent stored cross-site scripting attacks.

- Add getSafeId() to SwarmNode for XSS-safe HTML element IDs
- Escape node hostname, role, and service names with <j:out> tags
- Escape build display names and queue item values
- Sanitize JSON output to prevent </script> tag injection
Cherry-picked from jenkinsci#130.
Adds volumeDir field to agent template for specifying plain Docker
volumes, improves cacheDir help, sets default cache driver to local.
Cherry-picked Java changes from jenkinsci#137.
Docker API 1.44 deprecated ServiceSpec.Networks in favor of
TaskTemplate.Networks. Without this fix, Docker 29+ starts agents
on the bridge network instead of the configured swarm network.
Cherry-picked from jenkinsci#133, with additional
dependency cleanup: remove old pinned jackson/docker-java-api versions,
let BOM manage versions, add jackson2-api plugin dependency.
Provide the standard agent launch command (curl agent.jar && java
hudson.remoting.jnlp.Main) as the default when unixCommand is empty,
matching the default shown in the config UI. Also annotate
ContainerSpec.Command with @JsonInclude(NON_EMPTY) so that an
explicitly empty command omits the field from JSON, letting Docker
use the image entrypoint.

Previously an empty command sent Command:[] to Docker, which could
override the image entrypoint depending on Docker version and Jackson
serialization context.
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.

1 participant