Patch Jenkins and delivery agent Java runtimes
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
# Runtime-only update for an existing Jenkins controller or trusted agent image.
|
||||
# BASE_IMAGE must be a local rollback tag verified against the running image ID.
|
||||
# The final image retains the application's version, tools, plugins and user.
|
||||
ARG BASE_IMAGE
|
||||
FROM eclipse-temurin:21.0.13.1_2-jdk-jammy@sha256:4b3d0998ee65462bd86ff060c87119b3575294cb3d0927372afa6f3708b0c8db AS patched_java
|
||||
FROM ${BASE_IMAGE}
|
||||
USER root
|
||||
RUN rm -rf /opt/java/openjdk
|
||||
COPY --from=patched_java /opt/java/openjdk /opt/java/openjdk
|
||||
ENV JAVA_VERSION=jdk-21.0.13.1+2
|
||||
USER jenkins
|
||||
RUN java -version
|
||||
@@ -0,0 +1,99 @@
|
||||
# Java runtime security maintenance - 23 November 2026
|
||||
|
||||
Vincent authorized patching CVE-2026-114938 after reviewing DigitalOcean's
|
||||
OpenJDK alert. This is operational maintenance, separate from the pending
|
||||
Assignment 9 Zammad setup. No commits or pushes were requested.
|
||||
|
||||
The running Jenkins controller used Temurin 21.0.12.1+1 and its trusted delivery
|
||||
agent used 21.0.13+9. Both were replaced with **Temurin 21.0.13.1+2**, which
|
||||
[Adoptium identifies as fixed](https://adoptium.net/news/2026/11/temurin-november-2026-cspu-java4shell).
|
||||
The Droplet's exposed CPU flags did not include AVX-512 VBMI; that is a required
|
||||
hardware condition for the documented exploit. Updating the runtimes avoids
|
||||
depending on that hardware limitation.
|
||||
|
||||
| Service | Updated image | Actual local image ID |
|
||||
| --- | --- | --- |
|
||||
| Jenkins controller | `ssw590-jenkins:2.580.1-java21.0.13.1-2` | `05067cf69fd76a98de8d434e7af9782cb9f979e0db3301760038da557cd5927b` |
|
||||
| Trusted delivery agent | `ssw590-delivery-agent:20261114-java21.0.13.1-2` | `8d6302db4598887010c11ee7de0f87b0f62ab92e53bf7ec1e81fbab98d9778a7` |
|
||||
|
||||
The official `eclipse-temurin:21.0.13.1_2-jdk-jammy` runtime stage is pinned to
|
||||
index digest `sha256:4b3d0998ee65462bd86ff060c87119b3575294cb3d0927372afa6f3708b0c8db`.
|
||||
Its Linux/amd64 manifest was
|
||||
`sha256:4e38bcd64a552586921cdd011831cabc0d56c4f7c950aa460c0b9e03237871ed`.
|
||||
Only `/opt/java/openjdk` and its descriptive `JAVA_VERSION` environment value
|
||||
were replaced in the existing application images. Jenkins remains 2.580.1;
|
||||
plugins, tools, identity and workspace were retained. No production release,
|
||||
approval, dependency upgrade or database migration was performed.
|
||||
|
||||
## Procedure and verification
|
||||
|
||||
`patch-existing.py` is deliberately specific to The-Ocean's two existing Compose
|
||||
projects. Review its paths before reuse. Its `prepare` action captures selected
|
||||
non-secret metadata, saves Compose copies, refuses unfinished/queued Jenkins
|
||||
work, pulls the pinned runtime and builds both images sequentially. Builds used
|
||||
512 MiB and 0.5 CPU limits. Isolated smoke containers have no network or data
|
||||
mounts and a read-only filesystem. The legacy builder warning was retained;
|
||||
this choice permits explicit build-container limits on this small host.
|
||||
|
||||
The `apply` action checks the checkpoint again, changes only the two image
|
||||
selectors, stops the idle agent, recreates the controller, waits for its login
|
||||
page, and recreates the agent. It verifies the fixed runtime, running state,
|
||||
absence of OOM kills, and identical persistent mounts. It does not automatically
|
||||
roll back after an error; inspect the checkpoint and service state first.
|
||||
|
||||
Executed verification confirmed Jenkins login HTTP 200 and the agent's
|
||||
`Connected` message. Gitea and Grafana private HTTP checks passed. The live
|
||||
controller Dockerfile was also updated to retain the fix on future builds;
|
||||
its original was preserved. The pricing containers, proxy, monitoring and
|
||||
manual runner were not recreated. No full release pipeline was triggered.
|
||||
|
||||
Selected-field evidence is retained in ignored
|
||||
`build/evidence/java-patch-20261123/`. On the Droplet, checkpoints and logs remain
|
||||
in root-only `/root/ssw590-java-patch-20261123/`. Credentials and full Docker
|
||||
inspect output are excluded. No additional cloud resource or plan was created;
|
||||
this used the existing paid Droplet, with transient CPU, storage and network use.
|
||||
|
||||
## Recovery
|
||||
|
||||
The original images retain the local tags
|
||||
`ssw590-java-rollback:jenkins-20261123` and
|
||||
`ssw590-java-rollback:agent-20261123` as recovery checkpoints. They contain the
|
||||
old runtime; do not select them during normal operation.
|
||||
|
||||
If the new runtime causes a verified operational regression, first stop or drain
|
||||
Jenkins work. On the authorized host, restore the corresponding saved Compose
|
||||
file from the root-only checkpoint directory to its original path:
|
||||
|
||||
- `jenkins-compose.before` -> `/root/gitea/docker-compose.yml`
|
||||
- `agent-compose.before` -> `/opt/ssw590-delivery-agent/compose.droplet.yaml`
|
||||
|
||||
Validate with `docker compose -f <original-path> config --quiet`, then recreate
|
||||
only that service using `up -d --no-deps --pull never <service>` from its project
|
||||
directory. Original image tags remain present. Preserve volumes and identities;
|
||||
never use `down -v`. Restoring the old controller Dockerfile is needed only if
|
||||
its future build recipe must also be reverted. If running the old Java build on
|
||||
affected hardware, the vendor's interim mitigation is
|
||||
`-XX:-UseBASE64Intrinsics` followed by a service restart.
|
||||
|
||||
Retain the checkpoint images and files until the group has reviewed the update.
|
||||
Do not prune shared Docker images, build caches or volumes to clean up this task.
|
||||
|
||||
## Scope limits
|
||||
|
||||
Local Zammad remains stopped and unchanged. Its Elasticsearch Java build also
|
||||
predates the fix, but the laptop's Docker VM was verified to lack AVX-512 VBMI.
|
||||
Review its official patched image before the next local setup session.
|
||||
The earlier PHP inventory found no PHP; this Java patch does not install PHP.
|
||||
The NGINX alert and its separately recorded HTTP/2 assessment remain separate.
|
||||
|
||||
For a future full source rebuild, the controller and agent Dockerfiles also
|
||||
copy the same pinned fixed Java stage. Build the agent from `delivery/`:
|
||||
|
||||
```sh
|
||||
docker build -f agent/Dockerfile -t ssw590-delivery-agent:20261114-java21.0.13.1-2 .
|
||||
```
|
||||
|
||||
Build the controller using its Compose project. Full source rebuild image IDs
|
||||
will differ from the runtime-only maintenance images above; verify Java again.
|
||||
The stopped laptop fallback requires the patched agent image to be built or
|
||||
loaded before it can be used. Never start it alongside the active cloud agent.
|
||||
@@ -0,0 +1,160 @@
|
||||
"""Targeted The-Ocean Java update; run as root after reviewing this file.
|
||||
|
||||
prepare builds and smoke-tests images without restarting services. apply
|
||||
requires those prepared images and refuses active/queued Jenkins work.
|
||||
Rollback copies and selected-field evidence remain outside the repository.
|
||||
"""
|
||||
import argparse
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
import subprocess
|
||||
import time
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
ROOT = Path('/root/ssw590-java-patch-20261123')
|
||||
JAVA_IMAGE = ('eclipse-temurin:21.0.13.1_2-jdk-jammy@'
|
||||
'sha256:4b3d0998ee65462bd86ff060c87119b3575294cb3d0927372afa6f3708b0c8db')
|
||||
SERVICES = [
|
||||
dict(name='gitea-jenkins-1', service='jenkins',
|
||||
directory='/root/gitea', compose='docker-compose.yml',
|
||||
image='ssw590-jenkins:2.580.1-java21.0.13.1-2'),
|
||||
dict(name='ssw590-delivery-agent-1', service='agent',
|
||||
directory='/opt/ssw590-delivery-agent', compose='compose.droplet.yaml',
|
||||
image='ssw590-delivery-agent:20261114-java21.0.13.1-2'),
|
||||
]
|
||||
|
||||
|
||||
def run(*args, capture=True, **kwargs):
|
||||
result = subprocess.run(args, check=True, text=True,
|
||||
stdout=subprocess.PIPE if capture else None,
|
||||
stderr=subprocess.STDOUT, **kwargs)
|
||||
return result.stdout.strip() if capture else ''
|
||||
|
||||
|
||||
def inspect(name):
|
||||
# Never serialize full inspect output: it can contain secret environment values.
|
||||
obj = json.loads(run('docker', 'inspect', name))[0]
|
||||
return dict(name=name, image=obj['Image'], reference=obj['Config']['Image'],
|
||||
running=obj['State']['Running'], oom=obj['State']['OOMKilled'],
|
||||
restarts=obj['RestartCount'],
|
||||
mounts=[dict(type=m['Type'], source=m['Source'],
|
||||
destination=m['Destination'], rw=m['RW'])
|
||||
for m in obj['Mounts']])
|
||||
|
||||
|
||||
def assert_idle():
|
||||
home = Path(run('docker', 'volume', 'inspect', '-f', '{{.Mountpoint}}',
|
||||
'gitea_jenkins-home'))
|
||||
active = []
|
||||
for path in (home / 'jobs').rglob('build.xml'):
|
||||
tree = ET.parse(path).getroot()
|
||||
if tree.find('result') is None:
|
||||
active.append(str(path.relative_to(home)))
|
||||
assert not active, 'Refusing restart: unfinished Jenkins builds: ' + repr(active)
|
||||
queue = home / 'queue.xml'
|
||||
if queue.exists():
|
||||
tree = ET.parse(queue).getroot()
|
||||
assert not list(tree.iter('item')), 'Refusing restart: Jenkins queue is nonempty'
|
||||
for items in tree.iter('items'):
|
||||
assert not list(items), 'Refusing restart: Jenkins queue contains work'
|
||||
|
||||
|
||||
def smoke(image):
|
||||
result = run('docker', 'run', '--rm', '--pull', 'never', '--network', 'none',
|
||||
'--read-only', '--cap-drop', 'ALL', '--security-opt',
|
||||
'no-new-privileges', '--entrypoint', 'java', image, '-version')
|
||||
assert '21.0.13.1' in result and '+2' in result, result
|
||||
return result
|
||||
|
||||
|
||||
def compose(spec, *args):
|
||||
return run('docker', 'compose', '-f', spec['compose'], *args,
|
||||
cwd=spec['directory'])
|
||||
|
||||
|
||||
def prepare():
|
||||
ROOT.mkdir(mode=0o700, exist_ok=True)
|
||||
os.chmod(ROOT, 0o700)
|
||||
before_path = ROOT / 'before.json'
|
||||
if before_path.exists():
|
||||
before = json.loads(before_path.read_text())
|
||||
assert [inspect(s['name'])['image'] for s in SERVICES] == [
|
||||
s['image'] for s in before], 'Current images differ from original checkpoint'
|
||||
else:
|
||||
before = [inspect(s['name']) for s in SERVICES]
|
||||
before_path.write_text(json.dumps(before, indent=2) + '\n')
|
||||
for spec in SERVICES:
|
||||
shutil.copy2(Path(spec['directory']) / spec['compose'],
|
||||
ROOT / (spec['service'] + '-compose.before'))
|
||||
assert_idle()
|
||||
run('docker', 'pull', JAVA_IMAGE, capture=False)
|
||||
smoke(JAVA_IMAGE)
|
||||
env = dict(os.environ, DOCKER_BUILDKIT='0')
|
||||
# No application state, Compose backup or evidence enters the build context.
|
||||
context = ROOT / 'empty-context'
|
||||
context.mkdir(exist_ok=True)
|
||||
built = []
|
||||
for spec, old in zip(SERVICES, before):
|
||||
rollback = 'ssw590-java-rollback:' + spec['service'] + '-20261123'
|
||||
run('docker', 'tag', old['image'], rollback)
|
||||
run('docker', 'build', '--pull=false', '--memory', '512m',
|
||||
'--cpu-quota', '50000', '--build-arg', 'BASE_IMAGE=' + rollback,
|
||||
'-t', spec['image'], '-f', str(ROOT / 'Dockerfile'), str(context),
|
||||
env=env, capture=False)
|
||||
built.append(dict(name=spec['name'], reference=spec['image'],
|
||||
image=run('docker', 'image', 'inspect', '-f', '{{.Id}}', spec['image']),
|
||||
java=smoke(spec['image']), rollback=rollback))
|
||||
(ROOT / 'prepared.json').write_text(json.dumps(built, indent=2) + '\n')
|
||||
print(json.dumps(built, indent=2))
|
||||
|
||||
|
||||
def apply():
|
||||
before = json.loads((ROOT / 'before.json').read_text())
|
||||
prepared = json.loads((ROOT / 'prepared.json').read_text())
|
||||
assert_idle()
|
||||
for spec, old, built in zip(SERVICES, before, prepared):
|
||||
assert inspect(spec['name'])['image'] == old['image'], 'Unexpected current image'
|
||||
assert run('docker', 'image', 'inspect', '-f', '{{.Id}}', spec['image']) == built['image']
|
||||
path = Path(spec['directory']) / spec['compose']
|
||||
assert path.read_bytes() == (ROOT / (spec['service'] + '-compose.before')).read_bytes(), 'Compose changed after preparation'
|
||||
source = path.read_text()
|
||||
needle = 'image: ' + old['reference']
|
||||
assert source.count(needle) == 1, 'Expected exactly one original image selector'
|
||||
path.write_text(source.replace(needle, 'image: ' + spec['image']))
|
||||
compose(spec, 'config', '--quiet')
|
||||
# Stop the idle agent first so no delivery job can start during maintenance.
|
||||
compose(SERVICES[1], 'stop', '-t', '30', 'agent')
|
||||
compose(SERVICES[0], 'up', '-d', '--no-deps', '--pull', 'never', 'jenkins')
|
||||
for _ in range(60):
|
||||
try:
|
||||
code = run('docker', 'exec', SERVICES[0]['name'], 'curl', '-sS',
|
||||
'--max-time', '5', '-o', '/dev/null', '-w', '%{http_code}',
|
||||
'http://localhost:8080/login') if inspect(SERVICES[0]['name'])['running'] else '000'
|
||||
except subprocess.CalledProcessError:
|
||||
code = '000'
|
||||
if code == '200':
|
||||
break
|
||||
time.sleep(3)
|
||||
else:
|
||||
raise RuntimeError('Controller did not return HTTP 200; retain checkpoint and investigate')
|
||||
compose(SERVICES[1], 'up', '-d', '--no-deps', '--pull', 'never', 'agent')
|
||||
after = []
|
||||
for spec, old in zip(SERVICES, before):
|
||||
now = inspect(spec['name'])
|
||||
assert now['running'] and not now['oom']
|
||||
assert now['mounts'] == old['mounts'], 'Persistent mounts changed'
|
||||
now['java'] = run('docker', 'exec', spec['name'], 'java', '-version')
|
||||
assert '21.0.13.1' in now['java'] and '+2' in now['java']
|
||||
after.append(now)
|
||||
(ROOT / 'after.json').write_text(json.dumps(after, indent=2) + '\n')
|
||||
print(json.dumps(after, indent=2))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('action', choices=['prepare', 'apply'])
|
||||
args = parser.parse_args()
|
||||
assert os.geteuid() == 0, 'Run as root on the authorized host'
|
||||
{'prepare': prepare, 'apply': apply}[args.action]()
|
||||
Reference in New Issue
Block a user