Skip to content

Conversation

@adoroszlai
Copy link
Contributor

What changes were proposed in this pull request?

Introduce ABORTED state for topology host requests (cluster creation, scale hosts) to handle errors that happen in the pre-stage phase (during configure cluster task and other topology tasks). Return such state and cause of failure in requests API (cause is returned in request_context).

https://issues.apache.org/jira/browse/AMBARI-22805

How was this patch tested?

Tested the following scenarios:

  • cluster installation from scratch:
    • successful one
    • with wrong Kerberos admin credential
    • invalid blueprint (no NAMENODE)
  • upscale cluster:
    • directly after install
    • scale request before restart, agent started after server restart
    • both scale request and agent start issued after restart
  • upscale cluster with missing Kerberos credentials (same scenarios)
  • upgrade from Ambari 2.6.1
  • upscale cluster after upgrade

Unit tests:

...
Tests run: 4943, Failures: 0, Errors: 0, Skipped: 34
...
Total run:1201
Total errors:0
Total failures:0
OK
...
BUILD SUCCESS

Sample failed cluster creation:

{
  "href" : "http://localhost:8080/api/v1/clusters/TEST/requests/1",
  "Requests" : {
    "cluster_name" : "TEST",
    "id" : 1,
    "progress_percent" : -1.0,
    "request_context" : "Logical Request: Provision Cluster 'TEST'\nFAILED: Missing KDC administrator credentials.",
    "request_status" : "ABORTED"
  }
}

@rnettleton @mhmxs

@asfgit
Copy link

asfgit commented Jan 18, 2018

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/Ambari-Github-PullRequest-Builder/190/
Test PASSed.

@adoroszlai adoroszlai merged commit 4b49902 into apache:branch-2.6 Jan 19, 2018
AndresMaqueo added a commit to AndresMaqueo/ambari that referenced this pull request Dec 31, 2025
… entity in user-controlled data

### Context

This commit addresses a critical CodeQL finding (`java/xxe`) related to XML External Entity (XXE) processing in user-controlled XML data.

The affected code path parses XML input without explicitly disabling DTDs and external entity resolution, which could allow XXE-based attacks such as:
- Arbitrary file access
- Server-side request forgery (SSRF)
- Denial of service

### Change summary

This change hardens the XML parsing configuration in `VersionDefinitionXml.load(InputStream)` by applying defensive parser settings recommended by OWASP and standard Java security guidance:

**XMLInputFactory**
- Explicitly disables DTD support
- Explicitly disables external entity resolution

**SchemaFactory**
- Enables JAXP secure processing
- Disables access to external DTDs and schemas (where supported)

All settings are applied defensively using try/catch blocks to preserve compatibility with different JAXP implementations.

### Impact

- No functional or behavioral changes for valid XML inputs
- Malicious XML relying on external entities or DTDs will now fail to parse
- Improves overall security posture without affecting business logic

### Notes

- This change is limited in scope to XML parser hardening
- No changes were made to higher-level logic or data flow
- The fix is intentionally minimal and focused on security hardening

Fixes: CodeQL alert apache#146

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
AndresMaqueo added a commit to AndresMaqueo/ambari that referenced this pull request Dec 31, 2025
Fixes CodeQL alert apache#146.

This merge hardens XML parsing against XXE by disabling DTDs and external entity resolution.
The change is intentionally minimal and limited to parser configuration only.
No functional or behavioral changes outside XML parsing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants