Skip to content

Add support for AWS credential_process configuration, allowing external processes to provide temporary AWS credentials.#17864

Open
dkocher wants to merge 3 commits intomasterfrom
feature/GH-11664
Open

Add support for AWS credential_process configuration, allowing external processes to provide temporary AWS credentials.#17864
dkocher wants to merge 3 commits intomasterfrom
feature/GH-11664

Conversation

@dkocher
Copy link
Contributor

@dkocher dkocher commented Feb 8, 2026

Fix #11664.

@dkocher dkocher added this to the 9.4 milestone Feb 8, 2026
@dkocher dkocher requested a review from Copilot February 8, 2026 21:41
@dkocher dkocher added the s3 AWS S3 Protocol Implementation label Feb 8, 2026
@dkocher dkocher requested a review from a team as a code owner February 8, 2026 21:41
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds support for AWS credential_process in Cyberduck’s S3 credential auto-configuration so profiles can source temporary credentials from an external command (issue #11664).

Changes:

  • Execute credential_process commands for process-based AWS profiles and parse returned JSON into TemporaryAccessTokens.
  • Update AWS SDK BOM version (likely to pick up BasicProfile support for process-based profiles).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
s3/src/main/java/ch/cyberduck/core/s3/S3CredentialsConfigurator.java Adds credential_process handling by launching an external process and mapping JSON output to temporary tokens.
pom.xml Bumps aws-java-sdk-bom from 1.12.778 to 1.12.797.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +129 to +131
catch(IOException e) {
log.warn("Failure \"{}\" parsing cached credentials from {}", e.getMessage(), command);
return credentials;
Copy link

Copilot AI Feb 8, 2026

Choose a reason for hiding this comment

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

The warning message says "parsing cached credentials" but this path is parsing credential_process output, not a cache file, and it drops useful failure details like exit code and stderr. Updating the log message (and including stderr/exit status) will make troubleshooting misconfigured profiles much easier.

Copilot uses AI. Check for mistakes.
Comment on lines +100 to +103
if(profile.isProcessBasedProfile()) {
// Uses external process to retrieve temporary credentials
final String command = profile.getCredentialProcess();
final ObjectMapper mapper = JsonMapper.builder()
Copy link

Copilot AI Feb 8, 2026

Choose a reason for hiding this comment

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

New credential_process support isn’t covered by tests, while this class already has dedicated unit tests and fixtures for other profile types. Add a test profile in src/test/resources/.../.aws plus a test that runs a small helper command (or a mocked process runner) returning the expected JSON, and assert the parsed tokens/expiry are applied.

Copilot uses AI. Check for mistakes.
Comment on lines +109 to +119
switch(Factory.Platform.getDefault()) {
case windows:
cmd.add("cmd");
cmd.add("/c");
break;
default:
cmd.add("sh");
cmd.add("-c");
break;
}
cmd.add(command);
Copy link

Copilot AI Feb 8, 2026

Choose a reason for hiding this comment

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

Using cmd /c or sh -c runs the credential_process through a shell, which changes quoting/escaping semantics and expands shell metacharacters. AWS credential_process is typically executed as a direct process invocation; consider parsing the command into an argv list and calling ProcessBuilder without a shell to better match expected behavior and reduce unintended command interpretation.

Copilot uses AI. Check for mistakes.
Comment on lines 120 to 127
final ProcessBuilder builder = new ProcessBuilder(cmd);
try {
final Process process = builder.start();
try(InputStream reader = process.getInputStream()) {
final CachedCredential cached = mapper.readValue(reader, CachedCredential.class);
return credentials.setTokens(new TemporaryAccessTokens(
cached.accessKey, cached.secretKey, cached.sessionToken, Instant.parse(cached.expiration).toEpochMilli()));
}
Copy link

Copilot AI Feb 8, 2026

Choose a reason for hiding this comment

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

credential_process execution reads only stdout and never checks exit status or drains stderr; a process that writes to stderr (or never exits) can deadlock or block login. Consider redirecting stderr (or consuming it), waiting for the process to finish (with a timeout), and logging stderr/exit code on failure before falling back to existing credentials.

Copilot uses AI. Check for mistakes.
@dkocher dkocher requested a review from ylangisc February 10, 2026 07:20
@ylangisc ylangisc modified the milestones: 9.4, 9.5 Feb 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

s3 AWS S3 Protocol Implementation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support credentials_process in ~/.aws/credentials profile

2 participants