Skip to content

Update OS baseline and reduce container attack surface#2

Open
xuara wants to merge 34 commits into
mainfrom
fix/security-updates-140
Open

Update OS baseline and reduce container attack surface#2
xuara wants to merge 34 commits into
mainfrom
fix/security-updates-140

Conversation

@xuara
Copy link
Copy Markdown
Owner

@xuara xuara commented May 14, 2026

Summary

This PR updates the container base image to Ubuntu 26.04 (Resolute Raccoon) to improve the security posture of the application.

Key Improvements

  • Vulnerability Reduction: This update successfully eliminates 80% of total vulnerabilities found in the current production environment.
  • Attack Surface Reduction: By moving to the new baseline, we removed 274 unnecessary packages, resulting in a 57% leaner image profile.
  • Multi-Arch Support: The Dockerfile logic has been updated to ensure builds remain stable for amd64, arm64, and arm/v7 architectures.
  • Dependency Management: I retained the standard Ubuntu base to ensure apt-get remains available for necessary package installations.

Technical Blockers

While this significantly hardens the image, 11 vulnerabilities remain because they are inherent to the upstream Microsoft base images and cannot be fixed at our level:

  • Go stdlib 1.26.2: This package contains 5 High and 3 Medium vulnerabilities, including CVE-2026-42499. A full fix requires version 1.26.3.
  • golang.org/x/net 0.40.0: This transitive dependency contains 1 High and 2 Medium vulnerabilities that require version 0.53.0 for remediation.

Impact

Moving to the latest LTS release provides a much cleaner environment by remediating unpatchable vulnerabilities in packages like curl and otel/sdk, even while we wait for upstream toolchain updates to clear the remaining Go-related items.

xuara and others added 30 commits May 12, 2026 04:35
…korecko#140)

- Resolved 18 High and 26 Medium vulnerabilities (CVE-2026-42499, etc.) by upgrading OS packages.
- Addressed transitive Go-based vulnerabilities within the Docker CLI and system libraries.
- Restructured build into explicit stages (base, build, final) for better security isolation.
- Implemented GPG key verification for Docker repository to ensure package integrity.
- Maintained non-root 'app' user execution for production hardening.
- Minor comment adjustment to trigger GitHub Actions build.
- Verifying multi-stage Dockerfile logic and architecture mapping.
- Added temporary workflow to verify Dockerfile syntax and multi-stage logic.
- Ensuring apt-get upgrade and GPG key verification work as intended.
- Validating non-root user transitions.
- Created docker-build-check.yml to automate Dockerfile validation.
- Configured to trigger on push, pull_request, and manual dispatch.
- Ensures future changes to the Dockerfile do not break image builds.
- Upgraded docker/setup-buildx-action to v4.
- Upgraded docker/login-action to v4.
- Upgraded docker/build-push-action to v7.
- Added id-token permissions for OIDC build attestations.
- Refactored GHCR login to use GITHUB_TOKEN for improved security.
- Simplified tag generation using native GitHub context variables.
- Enabled NuGet package caching in setup-dotnet@v4 for faster CI cycles.
- Hardened security by reducing GITHUB_TOKEN permissions to read-only.
- Standardized checkout logic for Pull Request triggers.
- Added normal verbosity to test output for better mobile debugging.
- Upgraded Docker actions to v4 (setup/login) and v7 (build-push).
- Implemented OIDC id-token permissions for secure build provenance.
- Refactored GHCR auth to use native GITHUB_TOKEN.
- Optimized multi-arch test matrix by replacing 50s sleep with direct binary verification.
- Standardized architecture naming for arm/v7 across workflows.
- Corrected Buildx setup to use docker/setup-buildx-action@v4.
- Migrated raw docker build command to docker/build-push-action@v7.
- Enabled GitHub Actions (GHA) caching for faster subsequent builds.
- Set push to false to ensure this remains a validation-only check.
- Removed 'cache: true' from setup-dotnet@v4.
- Resolved "Dependencies lock file is not found" error.
- Standardized build workflow for repositories without packages.lock.json.
- Upgraded base and build images to `10.0-resolute` (Ubuntu 24.04 -> 26.04).
- Remediates 8 High/Medium CVEs (inc. CVE-2026-42499) in Go `stdlib 1.26.2`.
- Vulnerabilities were transitive via `docker-ce-cli` and OS-level system utilities.
- Resolute baseline provides Go `1.26.3+` binaries, addressing the security lag in Noble.
- Maintained `apt-get` support while reducing total package footprint by 50%.
…ages

Reverted to the stable Dockerfile structure from the main branch to fix permission errors while explicitly using 10.0-resolute tags for CVE remediation.
Refactored Dockerfile for performance and security:
- Fixed non-root permission errors using atomic 'install' and native '--chown'.
- Reduced image bloat by eliminating redundant filesystem layers.
- Minimized attack surface by purging build-time tools (gnupg) from the final stage.
- Improved build reproducibility by removing non-deterministic 'apt-get upgrade' calls.
- Standardized multi-arch RID mapping for amd64, arm64, and arm/v7.
Set environment variable to force JavaScript actions to Node.js 24.
…lities

Upgrades TargetFramework to net10.0 across the web and unit test projects. Aligns Entity Framework Core dependencies with version 10.0.0 and updates test runners for compatibility. Implements explicit package overrides for golang.org/x/net, spdystream, and OpenTelemetry to remediate high-severity CVEs identified in transitive Go-based dependencies.
Removes non-NuGet Go package references from project files to resolve dotnet restore errors during build. Retains TargetFramework upgrades to net10.0 and Entity Framework Core 10.0 alignment.
Extends FORCE_JAVASCRIPT_ACTIONS_TO_NODE24 to build, release,
and unstable workflows. This synchronizes with existing
docker-build settings and ensures compatibility with the
Ubuntu 26.04 (Resolute Raccoon) environment.
…de analysis

- Updated base image to Ubuntu 26.04 and SDK to .NET 10.0.
- Patched System.Security.Cryptography.Xml to 10.0.6 to resolve high-severity vulnerabilities.
- Refactored Constants to PascalCase and flattened structure.
- Internalized types (CA1515) and resolved all latest-all analyzer warnings.
- Synchronized unit tests with new naming and visibility standards.
- Internalized controllers and DTOs.
- Added standard exception constructors to custom exceptions.
- Fully aligned codebase with .NET 10 'latest-all' analysis standards.
Addresses all static analysis warnings and modernizes core services to
achieve a strict zero-warning build under .NET 10. This includes fixes
for memory leaks, routing performance, and background task reliability.

Resource Management & Memory Safety (CA2000):
- Enforced proper disposal of StringContent via 'using' declarations in
  PortainerService and OllamaService to prevent connection leaks.

Performance Optimization (CA2234, SYSLIB1045):
- Refactored HttpClient calls across AppriseService, DiscordService,
  PortainerService, and OllamaService to use Uri overloads, eliminating
  repeated string parsing overhead.
- Migrated runtime regex evaluations to compile-time [GeneratedRegex]
  partial methods in UpdateService and ParsingHelper for improved performance.
- Resolved collection initialization warnings (IDE0305) in ParsingHelper
  using modern collection expressions [.. ].

Service Reliability & Task Cancellation (CA1031):
- Replaced broad catch-all blocks across background workers (DockerService,
  UpdateService, VersionCheckHostedService, ParsingHelper).
- Added explicit 'when (ex is not OperationCanceledException)' filters to
  allow graceful shutdown and propagation of cancellation tokens.
…tests

- Fix Unhandled ArgumentNullException in UpdateService when config path reads fail
- Enforce regex matching against app.Version instead of the raw variable block in .env update strategy
- Add strict validation checks to prevent incomplete (fewer than 3 steps) update plans from executing
- Update test suite Moq configurations to dynamically handle absolute paths for .env resolution
- Fix exact match string constraint bugs in UpdateServiceTests test hooks
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