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

User-defined variables are not replaced when Global Variables are used #3030

Closed
lincoln123lin opened this issue Jul 30, 2024 · 5 comments · Fixed by mitre/magma#66
Closed
Assignees
Labels

Comments

@lincoln123lin
Copy link

Describe the bug
User-defined variables are not populated when global variables are used in the ability execution inside an operation.

To Reproduce
Steps to reproduce the behavior:

  1. Create a new operation
  2. Launch any ability with global variables #{origin_link_id} and #{server} and some user-defined variables. Give values to all the user-defined abilities and leave the global variables empty
  3. Observe the output command

Expected behavior
The command has an obfuscated and a plaintext version of the commands, with the command in obfuscated having the origin_link_id but the plaintext does not. The user-defined abilities are not defined in both cases.

Screenshots
image

Desktop (please complete the following information):

  • OS: Windows (Caldera server running on Ubuntu)
  • Browser: Firefox
  • Version: 5.0.0

Additional context
In my screenshot, I am running my own custom ability. But the best default ability that fits this bug scenario is "Service Creation". The only user-defined ability is #{remote.host.fqdn} so recommended to modify it to add additional variables to make the reproduction realistic.

Copy link

Looks like your first issue -- we aim to respond to issues as quickly as possible. In the meantime, check out our documentation here: http://caldera.readthedocs.io/

@d3vco
Copy link
Contributor

d3vco commented Aug 29, 2024

This issue is related to another issue (or inconvenience, maybe?) - if values aren't supplied for all fact templates in an ability, then none of the values are substituted in. Depending on when/how the global facts are inserted, both of these issues could have the same solution.

I suggest that the default behavior should be: any provided values should be substituted for the relevant fact template, regardless if values have been provided for all fact templates.

To Reproduce Related Issue:

  1. In a new operation, open "Add Potential Link".
  2. Select the "Fingerprint network services" ability.
  3. Modify the command by removing -p #{remote.host.port} (final command should read nmap -sV #{remote.host.ip}).
  4. Type in a value for remote.host.ip. Leave remote.host.port blank / don't select a value.
  5. Add potential link.
  6. Note that the IP value you entered does not get substituted into the command. The executed command will be nmap -sV #{remote.host.ip} and the link will fail.

@lincoln123lin
Copy link
Author

lincoln123lin commented Sep 10, 2024

Right now, the only way to work with this 'inconvenience' is to supply all the related global variables with a value when executing the ability in an operation. E.g. for the variable #{server} you will give a value of "http://<server address>:8888" instead of leaving it blank.

However, if we are to use the #{origin_link_id} for lateral movement, the link id is generated on-the-fly, and we won't know the link_id beforehand. So we won't be able to supply a value for it.

P.S. realise the issue is lying on the frontend of the operations page. Sending a POST request to Caldera via curl/request does not have any such issues.

@elegantmoose
Copy link
Contributor

Yikes, yea this an annoying 'inconvenience'. Looking at PR on magma repo from @d3vco now.

@elegantmoose
Copy link
Contributor

merged @d3vco's fix.

Reopen if still having problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants