Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Env variable value exposure using multienv with incorrect variable in the chain #5315

Open
bazilmarkov opened this issue Feb 11, 2025 · 1 comment
Labels
bug Something isn't working security

Comments

@bazilmarkov
Copy link

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request. Searching for pre-existing feature requests helps us consolidate datapoints for identical requirements into a single place, thank you!
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment.

Overview of the Issue

By utilizing atlantis multienv configuration, exposing the entire chain of environmental variables values is possible if one of the variables has an invalid definition.

Reproduction Steps

test.sh returning the multiple environmental variables

#!/bin/bash
set -eu
set -o pipefail

VAR1=value1
VAR2="{\"error\":[\"error:\n\t*\"]}"
echo "VAR1=$VAR1,VAR2=$VAR2"

Repo.yaml

workflows:
  terraform:
    plan:
      steps:
        - multienv:
            command: './test.sh'
            shell: bash

Logs

Invalid environment variable definition: VAR1=value1,VAR2={"error":["error:\n\t*"]}

As a result, the VAR1 value is exposed. Expected behavior - only VAR2-related error is returned

Environment details

  • Atlantis version: 0.33.0
  • Deployment method: docker
@bazilmarkov bazilmarkov added the bug Something isn't working label Feb 11, 2025
Copy link

dosubot bot commented Feb 11, 2025

Hey @bazilmarkov 👋, I'm here to help you with any bugs, questions, or contributions you have. Let's work on resolving your issue together!

I found a similar open issue titled "multienv should not read from stderr" which might be related to your concern about error handling in the multienv command. This issue was last updated on October 09, 2024, but it currently has no comments or references [1].

Regarding your issue, the multienv command in Atlantis is designed to handle environment variable parsing and error reporting. If an invalid environment variable definition is encountered, it should return an error message indicating the invalidity, such as "Invalid environment variable definition" followed by the problematic input. However, it seems that in your case, the error handling is exposing the value of VAR1 when VAR2 has an invalid definition [2].

This behavior might be due to how the parseMultienvLine function processes the input string and handles errors. The function is supposed to return specific errors for invalid syntax, misquoted values, or remaining unparsed data, and the Run method formats these errors into a user-friendly message [2].

To address this, you might want to ensure that the error handling logic in your script or configuration is correctly set up to prevent exposure of valid environment variable values when an error occurs. If this is a bug or unexpected behavior, it might be worth reporting it as an issue in the Atlantis repository for further investigation.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other

@dosubot dosubot bot added the security label Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working security
Projects
None yet
Development

No branches or pull requests

1 participant