Skip to content

Feature/api secure enpoints#468

Closed
apeiris wants to merge 2 commits into
OpenAS2:masterfrom
apeiris:feature/api-secure-enpoints
Closed

Feature/api secure enpoints#468
apeiris wants to merge 2 commits into
OpenAS2:masterfrom
apeiris:feature/api-secure-enpoints

Conversation

@apeiris

@apeiris apeiris commented Aug 29, 2025

Copy link
Copy Markdown
Contributor

Add Jakarta WS RS API dependency and enhance ApiResource XML/JSON handling

  • Added jakarta.ws.rs-api in pom.xml
  • Refactored ApiResource to:
    • Add getPropertyList endpoint with sensitive property redaction
    • Improve getXml endpoint with proper XML parsing, XXE protection, and sensitive attribute removal
    • Implement redactSensitiveAttributes method to remove password/pwd fields from XML nodes

…dling

- Added jakarta.ws.rs-api in pom.xml
- Refactored ApiResource to:
  - Add getPropertyList endpoint with sensitive property redaction
  - Improve getXml endpoint with proper XML parsing, XXE protection, and sensitive attribute removal
  - Implement redactSensitiveAttributes method to remove password/pwd fields from XML nodes
}

@GET
@RolesAllowed({"ADMIN"})

Check failure

Code scanning / CodeQL

XPath injection Critical

XPath expression depends on a
user-provided value
.
Comment thread Server/pom.xml
Comment on lines +307 to +310
<dependency>
<groupId>jakarta.ws.rs</groupId>
<artifactId>jakarta.ws.rs-api</artifactId>
</dependency>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is a duplicate - the jakarta.ws.rs-api dependency is already defined on line 281 of this file.
Please remove.

@Path("/getXml")
@Produces({MediaType.APPLICATION_XML,MediaType.APPLICATION_JSON})
public Response getXml(@Context Request request,
@QueryParam("filename") String filename,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

To be clear:
I will not support passing in a filename to be retrieved. It is a security risk since the user could pass a path to any file on the server using '../../etc'

If you are only interested in the partnerships XML file then there is no need to pass in a file name at all.
Additionally, the file names should not need to be known by the user of the UI and the partnerships file could be located anywhere on the server using any user defined name for the file itself so you should be retrieving the file using the call to the partnership factory method.

If you feel there is a need to retrieve more than just the partnerships XML file from the file system then you should pass in an identifier and map the supported set of identifiers to appropriate getters to retrieve the file.

If you want to be able to retrieve the config XML file then please provide a use case as the config.xml is not really intended to be modifed directly but instead controlled by properties set in an external properties file and I do not see what the benefit of retrieving the config XML file would be.

The partnerships file path can be retrieved using this:
String partnershipsFile = getProcessor().getSession(). getPartnershipFactory().getFilename()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the clarification — I agree with your concern around not exposing filenames directly and avoiding path traversal risks.

One point of clarification: there isn’t currently an existing method like

String partnershipsFile = getProcessor().getSession().getPartnershipFactory().getFilename();

in the codebase.

Given that, would it be acceptable if I implement a REST endpoint that returns the list of partnerships using:

getProcessor().getSession().getPartnershipFactory().getPartnerships();

This way, the endpoint exposes the in-memory partnerships directly via the factory without relying on file names, while keeping to the security and design guidelines you’ve outlined.

@uhurusurfa uhurusurfa Aug 30, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ah yes - the getFilename method in the XMLPartnershipFactory is not public so you would have to change the method to public then do this:
String partnershipsFile = ((XMLPartnershipFactory)getProcessor().getSession().getPartnershipFactory()).getFilename();

However, I will support accessing the list of partnerships directly.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks , I’d prefer accessing the list of partnerships directly. That approach feels cleaner

@uhurusurfa uhurusurfa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please remove the log file as well

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please remove this file

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

will do..

@apeiris apeiris closed this by deleting the head repository Aug 31, 2025
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.

3 participants