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

Mitigation storage fails when mongo not on localhost #1157

Closed
VakarisZ opened this issue May 11, 2021 · 2 comments
Closed

Mitigation storage fails when mongo not on localhost #1157

VakarisZ opened this issue May 11, 2021 · 2 comments
Labels
Bug An error, flaw, misbehavior or failure in the Monkey or Monkey Island. Complexity: Medium Impact: Low MITRE ATT&CK

Comments

@VakarisZ
Copy link
Contributor

Describe the bug

If custom mongodb location is provided, monkey island fails to create attack mitigation database collection with the following error:

2021-05-11 14:52:46,718 - setup.py:13 - setup() - INFO - Setting up the Monkey Island, this might take a while...

Traceback (most recent call last):

File "/monkey/monkey_island/cc/setup.py", line 22, in try_store_mitigations_on_mongo

raise errors.OperationFailure("Mitigation collection empty. Try dropping the collection and running again")

pymongo.errors.OperationFailure: Mitigation collection empty. Try dropping the collection and running again


During handling of the above exception, another exception occurred:


Traceback (most recent call last):

File "./monkey_island.py", line 21, in <module>

main(is_setup_only)

File "/monkey/monkey_island/cc/main.py", line 43, in main

start_island_server(should_setup_only)

File "/monkey/monkey_island/cc/main.py", line 59, in start_island_server

setup()

File "/monkey/monkey_island/cc/setup.py", line 14, in setup

try_store_mitigations_on_mongo()

File "/monkey/monkey_island/cc/setup.py", line 29, in try_store_mitigations_on_mongo

store_mitigations_on_mongo()

File "/monkey/monkey_island/cc/setup.py", line 42, in store_mitigations_on_mongo

mongo_object.save()

File "/monkey/lib/python3.7/site-packages/mongoengine/document.py", line 403, in save

self.ensure_indexes()

File "/monkey/lib/python3.7/site-packages/mongoengine/document.py", line 880, in ensure_indexes

collection = cls._get_collection()

File "/monkey/lib/python3.7/site-packages/mongoengine/document.py", line 215, in _get_collection

if cls._meta.get("auto_create_index", True) and db.client.is_primary:

File "/monkey/lib/python3.7/site-packages/pymongo/mongo_client.py", line 1031, in is_primary

return self._server_property('is_writable')

File "/monkey/lib/python3.7/site-packages/pymongo/mongo_client.py", line 856, in _server_property

writable_server_selector)

File "/monkey/lib/python3.7/site-packages/pymongo/topology.py", line 243, in select_server

address))

File "/monkey/lib/python3.7/site-packages/pymongo/topology.py", line 200, in select_servers

selector, server_timeout, address)

File "/monkey/lib/python3.7/site-packages/pymongo/topology.py", line 217, in _select_servers_loop

(self._error_message(selector), timeout, self.description))

pymongo.errors.ServerSelectionTimeoutError: localhost:27017: [Errno 111] Connection refused, Timeout: 30s, Topology Description: <TopologyDescription id: 609a9a3e8169e495cb16eeb8, topology_type: Single, servers: [<ServerDescription ('localhost', 27017) server_type: Unknown, rtt: None, error=AutoReconnect('localhost:27017: [Errno 111] Connection refused')>]>

Looks like the code there is trying to connect to localhost:27017 even though the environment flag is not localhost MONKEY_MONGO_URL=mongodb://172.26.32.1:27017/monkeyisland

To Reproduce

Steps to reproduce the behavior:

  1. Run mongodb docker container with:
docker run --name monkey-mongo -p 27017:27017 -v [DATABASE_PATH]:/data/db -d mongo:4.2
  1. Run the island container with:
docker run --name monkey-island -p 5000:5000 -p 5001:5001 --env MONKEY_MONGO_URL=mongodb://[HOST_IP]:27017/monkeyisland -d guardicore/monkey-island:1.10.0
  1. See error

Expected behavior

Monkey shouldn't fail on mitigation creation.

Machine version (please complete the following information):

  • OS: Windows
@VakarisZ VakarisZ added Bug An error, flaw, misbehavior or failure in the Monkey or Monkey Island. Complexity: Medium labels May 11, 2021
@mssalvatore
Copy link
Collaborator

Can this be handled as part of #1148?

@VakarisZ
Copy link
Contributor Author

ATT&CK report is getting removed in #2440

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug An error, flaw, misbehavior or failure in the Monkey or Monkey Island. Complexity: Medium Impact: Low MITRE ATT&CK
Projects
None yet
Development

No branches or pull requests

2 participants