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

Error awslambda.py L31 #1320

Open
cgaudit opened this issue Jun 15, 2021 · 6 comments
Open

Error awslambda.py L31 #1320

cgaudit opened this issue Jun 15, 2021 · 6 comments
Labels
enhancement New feature or request
Milestone

Comments

@cgaudit
Copy link

cgaudit commented Jun 15, 2021

Hi
I got the current error while scanning AWS env. which contains Lambda service.
2021-06-15 11:49:07 kali scout[1561] ERROR awslambda.py L31: Failed to get role from managed policies: An error occurred (NoSuchEntity) when calling the GetRole operation: The role with name XXX-dev-getAllTransactionsRole-XXX cannot be found.

What can be the reasons for not founding the Entity?

BR

@cgaudit cgaudit added the enhancement New feature or request label Jun 15, 2021
@lowSoA
Copy link
Contributor

lowSoA commented Jun 22, 2021

Could you please provide the --debug output?

@x4v13r64
Copy link
Collaborator

We've seen such errors a few times and my theory is that a role was configured on the Lambda which was then deleted. Would have to test to confirm.

@cgaudit
Copy link
Author

cgaudit commented Jun 27, 2021

{ "additional_details": null, "exception": "Failed to get role from managed policies: An error occurred (NoSuchEntity) when calling the GetRole operation: The role with name xxx-dev-getAllTransactionsRole-xxx cannot be found.", "file": "awslambda.py", "line": 31, "traceback": "Traceback (most recent call last):\n File \"/usr/local/lib/python3.9/dist-packages/ScoutSuite/providers/aws/facade/awslambda.py\", line 31, in get_role_with_managed_policies\n role = client.get_role(RoleName=role_name)['Role']\n File \"/usr/local/lib/python3.9/dist-packages/botocore/client.py\", line 386, in _api_call\n return self._make_api_call(operation_name, kwargs)\n File \"/usr/local/lib/python3.9/dist-packages/botocore/client.py\", line 705, in _make_api_call\n raise error_class(parsed_response, operation_name)\nbotocore.errorfactory.NoSuchEntityException: An error occurred (NoSuchEntity) when calling the GetRole operation: The role with name xxx-dev-getAllTransactionsRole-xxx cannot be found.\n" }

@cgaudit
Copy link
Author

cgaudit commented Jul 15, 2021

Hi @lowSoA,

Does that logs enrich us with any insights?

@x4v13r64 is that means that each time a role was deleted will trigger an error?

For which tests does SecurityAudit permission is necessary for?

BR

@lowSoA
Copy link
Contributor

lowSoA commented Sep 15, 2021

I can confirm this is the behavior in the case explained by @x4v13r64 above.

@Tzaoh
Copy link

Tzaoh commented Oct 5, 2021

A similar check to below existing one was done.

if "ResourceNotFoundException" not in str(e):
print_exception('Failed to get Lambda access policy: {}'.format(e))
return None

For this use case:

if "NoSuchEntityException" not in str(e.__class__):
print_exception('Failed to get role from managed policies: {}'.format(e))
return None

Although, we might want to consider to refactor a bit this class (and maybe others were similar things could be happening) in order to use the standard Boto3 exceptions. For this specific use case botocore.errorfactory.NoSuchEntityException could be used. Maybe exposing it from the awslambda.py facade could also be a good approach.

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

No branches or pull requests

4 participants