Skip to content

Upgrade the backend and require complete package security scans - #320

Draft
Vinosaamaa wants to merge 5 commits into
mainfrom
codex/319-supported-backend
Draft

Vinosaamaa wants to merge 5 commits into
mainfrom
codex/319-supported-backend

Conversation

@Vinosaamaa

@Vinosaamaa Vinosaamaa commented Sep 12, 2026

Copy link
Copy Markdown
Owner

User description

The first production image scan found 33 high/critical findings in the old backend. This repair moves the ten services to supported Spring Boot 4.0.8 and Spring Cloud 2025.1.3, applies the Tomcat 11.0.25 security fixes, and scans every packaged Java library with explicit coverage checks. Metadata-only scans cannot pass.

Existing JSON and endpoint contracts are preserved through the official Jackson 2 compatibility module, updated Gateway routing configuration and Flyway starter. New password hashes use versioned PBKDF2 so the existing 128-character forms work; existing BCrypt hashes remain readable. Production compatibility must advance before new hashes are stored.

Refs #319; unblocks the dependency portion of #243 and PR #315. The owning issue stays open through merged-main and native release-package verification.

Validation

  • Full Java 21 backend verification: 360 tests, zero failures/errors.
  • All ten actual application packages scanned: complete coverage of 749 per-package libraries, zero high/critical vulnerabilities and zero secret findings.
  • Three scanner regression cases prevent metadata-only, incomplete or vulnerable scans from passing.
  • Hosted full CI, real signed-in journeys and full CodeAnt review are required at the final head.

Architecture and operations

No service boundary or production migration SQL changes. Login performs both supported password work factors for missing, passwordless, legacy and current accounts; overlong legacy guesses cannot authenticate. Password encoding requires a deployment compatibility-epoch advance; legacy overlong BCrypt passwords require recovery. Source package scans supplement the native operating-system and infrastructure image scans in #243. Raw scan output is never published; only sanitized coverage, digests and advisory metadata are retained.

Design, implementation and system review: docs/architecture/supported-backend-and-security-scans.md. Verification log: docs/operations/issue-319-change-log.md.

Engineering impact

  • Architecture Review

Canonical record: architecture-review-supported-backend-runtime@1. The canonical receipt is docs/engineering/changes/pr-320.md.


CodeAnt-AI Description

Upgrade backend services and enforce complete packaged-library security scans

What Changed

  • Backend services now run on supported Spring Boot 4.0.8 and Spring Cloud 2025.1.3 dependencies, including the latest Tomcat security fixes.
  • Existing JSON responses, gateway routes, database migrations, and legacy BCrypt passwords remain compatible during the upgrade.
  • New passwords support the full advertised length, including Unicode characters, while malformed hashes and overlong legacy guesses are rejected safely.
  • Login attempts perform consistent password verification work for missing, passwordless, legacy, and current accounts.
  • CI now packages all ten services and requires every included Java library to be scanned for high or critical vulnerabilities and secrets before passing.
  • Security scan results retain only sanitized coverage and advisory summaries; temporary extracted packages and raw reports are removed after each scan.
  • Updated integration and security tests cover framework compatibility, password behavior, gateway requests, and incomplete or misleading scan coverage.

Impact

✅ Full-length and Unicode passwords work
✅ Safer and more consistent login failures
✅ Complete security coverage for all packaged Java libraries

💡 Usage Guide

Checking Your Pull Request

Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.

Talking to CodeAnt AI

Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

Preserve Org Learnings with CodeAnt

You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

Check Your Repository Health

To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.

@codeant-ai

codeant-ai Bot commented Sep 12, 2026

Copy link
Copy Markdown

🏁 CodeAnt Quality Gate Results

Commit: a34707ba
Scan Time: 2026-09-12 06:32:50 UTC

✅ Overall Status: PASSED

Quality Gate Details

Quality Gate Status Details
Duplicate Code ✅ PASSED 0.0% duplicated
SAST ✅ PASSED No security issues
IAC ✅ PASSED Rating S: No issues

View Full Results

@Vinosaamaa
Vinosaamaa force-pushed the codex/319-supported-backend branch from 7284e01 to d729300 Compare September 12, 2026 06:18
@Vinosaamaa

Copy link
Copy Markdown
Owner Author

@CodeAnt-AI: review

@codeant-ai

codeant-ai Bot commented Sep 12, 2026

Copy link
Copy Markdown

🤖 CodeAnt AI — Review Status

Status Commit Started (UTC) Finished (UTC)
✅ Reviewed your PR a34707b Sep 12, 2026 · 06:31 06:34
✅ Reviewed your PR f282801 Sep 12, 2026 · 06:25 06:27
✅ Reviewed your PR d729300 Sep 12, 2026 · 06:18 06:21

@codeant-ai

codeant-ai Bot commented Sep 12, 2026

Copy link
Copy Markdown

Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

@codeant-ai codeant-ai Bot added the size:XL This PR changes 500-999 lines, ignoring generated files label Sep 12, 2026
@codeant-ai

codeant-ai Bot commented Sep 12, 2026

Copy link
Copy Markdown

CodeAnt Nitpicks

1 code suggestion

1. The test leaves summary.json and .cache/backend-security-tests behind, so failed or repeated runs pollute the workspace with test artifacts.

Resource leak · scripts/security/backend-artifacts.test.mjs:41-46


11 custom suggestions

1. Split this catch-all predicate into focused route entries grouped by resource family, with explicit ordering for overlaps, so each routing responsibility can be reviewed and changed independently.

Custom_rule · backend/gateway-service/src/main/resources/application.yml:96


2. Do not run both expensive work factors on every normal login; verify the algorithm indicated by the stored prefix, migrate successful legacy BCrypt credentials to PBKDF2, and reserve dummy verification plus bounded rate limiting for unknown or malformed accounts.

Custom_rule · docs/architecture/supported-backend-and-security-scans.md:28


3. Compute vulnerability and secret counts while producing the sanitized findings, or return the derived data from assessReport, instead of flattening every finding here and then traversing the same report again below.

Custom_rule · scripts/security/backend-artifacts.mjs:16-17


4. Extract the per-module preparation, extraction, scan, and result-building logic into a dedicated helper so the orchestration function only manages module iteration, summary persistence, and the final gate.

Custom_rule · scripts/security/backend-artifacts.mjs:49-80


5. Use an isolated temporary directory for the cache and register teardown to remove it after the test; the current repository-local fixed path is shared across runs and leaves test artifacts behind.

Custom_rule · scripts/security/backend-artifacts.test.mjs:40-44


6. Cache the checksum-pinned Trivy archive or binary and download it only on a cache miss, while retaining checksum verification for downloaded data.

Custom_rule · .github/workflows/backend-security.yml:48-50


7. Remove this WebFlux-only codec configuration; the analytics service uses the MVC starter, so retain only the MVC converter setting to avoid dead, duplicated configuration.

Custom_rule · backend/analytics-service/src/main/resources/application.yml:6-7


8. Remove the WebFlux-only codecs configuration because this service uses spring-boot-starter-webmvc; retain only the MVC converters setting.

Custom_rule · backend/community-service/src/main/resources/application.yml:6-7


9. Remove the WebFlux codec setting because this service uses Spring MVC and does not include the WebFlux starter; keep only the MVC converter configuration.

Custom_rule · backend/media-service/src/main/resources/application.yml:6-7


10. Remove the unused WebFlux codec mapper configuration because this service uses Spring MVC; retain only the MVC converter mapper setting.

Custom_rule · backend/message-service/src/main/resources/application.yml:6-7


11. Remove the repeated packaged-library total and scan-coverage details, or reference the earlier canonical result instead, so these manually maintained figures cannot drift between verification entries.

Custom_rule · docs/operations/issue-319-change-log.md:25

Comment on lines +119 to +126
boolean currentFormat = passwordHash.startsWith("{pbkdf2-sha256-v1}");
boolean bcryptInputAllowed = password.getBytes(StandardCharsets.UTF_8).length <= 72;
// An overlong guess must still perform BCrypt work, but can never authenticate a legacy hash.
String bcryptInput = bcryptInputAllowed ? password : "non-account-timing-placeholder";
boolean legacyMatches = passwordEncoder.matches(bcryptInput,
currentFormat ? DUMMY_BCRYPT_HASH : passwordHash);
boolean currentMatches = passwordEncoder.matches(password,
currentFormat ? passwordHash : DUMMY_PASSWORD_HASH);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: A malformed stored hash with this prefix makes passwordEncoder.matches throw, so login returns 500 instead of the expected 401 response. [api mismatch]

Assessment: 🟠 Major · 🔁 Occurrence: Rarely

Use CodeAnt Skill Fix in Cursor Fix in VSCode Claude

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** backend/auth-service/src/main/java/com/chanter/auth/application/AuthSessionService.java
**Line:** 119:126
**Comment:**
	*Api Mismatch: A malformed stored hash with this prefix makes `passwordEncoder.matches` throw, so login returns 500 instead of the expected 401 response.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

Comment on lines +35 to +37
const cache = path.join(root, '.cache/backend-security');
fs.mkdirSync(cache, { recursive: true });
const run = fs.mkdtempSync(path.join(cache, 'run-'));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: Each run keeps extracted JARs and raw scanner reports in .cache, so repeated local or persistent-runner scans continuously consume disk space. [resource leak]

Assessment: 🟠 Major · 🔁 Occurrence: Sometimes

Use CodeAnt Skill Fix in Cursor Fix in VSCode Claude

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** scripts/security/backend-artifacts.mjs
**Line:** 35:37
**Comment:**
	*Resource Leak: Each run keeps extracted JARs and raw scanner reports in `.cache`, so repeated local or persistent-runner scans continuously consume disk space.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

@Vinosaamaa

Copy link
Copy Markdown
Owner Author

@CodeAnt-AI: review

@codeant-ai

codeant-ai Bot commented Sep 12, 2026

Copy link
Copy Markdown

Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

Comment thread scripts/security/backend-artifacts.mjs Outdated
Comment on lines +9 to +11
const libraries = new Set(results.filter(result => result.Type === 'jar')
.flatMap(result => result.Packages ?? [])
.map(pkg => pkg.FilePath?.replaceAll('\\', '/').split('/').at(-1)).filter(Boolean));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: Coverage matches only the filename, not BOOT-INF/lib; a jar elsewhere in the extracted package can falsely satisfy a missing library and let an incomplete scan pass. [incomplete implementation]

Assessment: 🟠 Major · 🔁 Occurrence: Rarely

Use CodeAnt Skill Fix in Cursor Fix in VSCode Claude

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** scripts/security/backend-artifacts.mjs
**Line:** 9:11
**Comment:**
	*Incomplete Implementation: Coverage matches only the filename, not `BOOT-INF/lib`; a jar elsewhere in the extracted package can falsely satisfy a missing library and let an incomplete scan pass.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

@Vinosaamaa

Copy link
Copy Markdown
Owner Author

@CodeAnt-AI: review

@codeant-ai

codeant-ai Bot commented Sep 12, 2026

Copy link
Copy Markdown

Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XL This PR changes 500-999 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant