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

Spaces in fact traits are being prefixed with backslashes #2814

Closed
dan-kir opened this issue Sep 5, 2023 · 14 comments
Closed

Spaces in fact traits are being prefixed with backslashes #2814

dan-kir opened this issue Sep 5, 2023 · 14 comments

Comments

@dan-kir
Copy link

dan-kir commented Sep 5, 2023

Describe the bug
Spaces in fact traits are being prefixed with backslashes when used in abilities.

This is causing problems when trying to seed an operation with a fact source that includes such traits.

To Reproduce
Steps to reproduce the behavior:

  1. Create a fact trait with spaces.
  2. Use the fact in an ability
  3. Any spaces are prefixed with backslashes.

Expected behavior

  1. Create a fact trait with spaces.
  2. Use the fact in an ability.
  3. The trait can be used as is without the backslash prefix.

Screenshots
Example fact trait:
Screenshot_2023-09-05_16-05-21

Example command being executed:
Screenshot_2023-09-05_16-14-18

Desktop (please complete the following information):

  • OS: Kali
  • Browser: Chrome
  • Version: Caldera latest

Additional context
Don't think the issue is with the agents. Tested both Sandcat and Ragdoll agents.

@github-actions
Copy link

github-actions bot commented Sep 5, 2023

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/

@idleninja
Copy link

I came to check if this had been previously reported as i too am experiencing the same unexpected behavior.

@github-actions
Copy link

github-actions bot commented Oct 7, 2023

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days

@dan-kir
Copy link
Author

dan-kir commented Oct 8, 2023

Bump.
I would still like to see a solution to this. Can draft a PR when I have the time to investigate.

Copy link

github-actions bot commented Nov 9, 2023

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days

@d3vco
Copy link
Contributor

d3vco commented Nov 13, 2023

@dan-kir what ability / plugin were you using when you encountered this issue?

I was not able to replicate when testing on an arbitrary ability (spaces were retained from fact to command), which makes me think it may be related to the ability or plugin that you are using.

@dan-kir
Copy link
Author

dan-kir commented Nov 15, 2023

@dan-kir what ability / plugin were you using when you encountered this issue?

I was not able to replicate when testing on an arbitrary ability (spaces were retained from fact to command), which makes me think it may be related to the ability or plugin that you are using.

In the provided screenshots, I am using a custom ability that simply sends a GET request using curl.

Copy link

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days

@elegantmoose
Copy link
Contributor

@dan-kir Still having issue?

@dan-kir
Copy link
Author

dan-kir commented Jan 8, 2024

@elegantmoose Yes still seeing spaces in facts being escaped when used in abilities. I can provide more examples if it will help.

@dan-kir
Copy link
Author

dan-kir commented Jan 8, 2024

Here is a simple example using modified ability 'Leave note (T1491)'

image
image
image
image

@d3vco
Copy link
Contributor

d3vco commented Jan 12, 2024

I still cannot replicate. I modified the Leave note ability as shown in your screenshots @dan-kir and I did not experience the space escaping behavior.

Screenshot 2024-01-12 175902

I will add that Facts do have a method that allows them to be escaped, but nothing you are doing should be calling that method.

@dan-kir
Copy link
Author

dan-kir commented Jan 15, 2024

That's it! That function is being called because I'm using a 'sh' executor.

I confirmed this was my problem by updating the 'escaped' function like so:

def escaped(self, executor):
        #if executor not in escape_ref:
        return self.value
        escaped_value = str(self.value)
        #for char in escape_ref[executor]['special']:
        #    escaped_value = escaped_value.replace(char, (escape_ref[executor]['escape_prefix'] + char))
        return escaped_value

This works for me in the short-term. Unsure what a long-term fix looks like. Could spaces be removed from the 'escape_ref' dictionary?

Copy link

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days

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

No branches or pull requests

5 participants