You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Platform: Python 3.7 running on 64bit Amazon Linux 2/3.1.4
Web server: nginx (default in AL2)
Today I was checking my worker environment logs and in the nginx access logs I found some request that were made by external agents (not coming from sqs daemon process in localhost).
After debugging I realized that this security problem is caused due to the security group I added to the worker environment (I made this on purpose to have access to the web env database - check this).
When you add a security group to an EC2 instance, the inbound rules that comes with it will be included as well. If your environment is a single instance environment (i.e. no load balancer involved) the security group of the web environment instance will contain the following inbound rule: 80 | TCP | 0.0.0.0/0
If you use that same security group for your worker, then everyone will be able to access it.
Note that in the case of a high availability environment (i.e. with load balancer), the inbound rule will limit traffic to the load balancer only, so in that scenario we won't have this security flaw.
I haven't tried this yet, but I think a better approach to the one described here is to edit the inbound rules of the RDS DB security group and add an entry for the worker instance security group. By doing that the database should accept connections from both environments and the worker should remain private always.
The text was updated successfully, but these errors were encountered:
@Mdelaf I am really glad you found this project useful.
Sorry for taking this long to reply – it's hard to track track of everything on holidays :)
I actually never set up an environment without a load-balancer, so I did not realize that this kind of situation is even possible, thanks for pointing it out and suggesting a solution.
May I ask if you have succeed in updating the inbound rules to eliminate the security risk? If so, could you please write the steps to set those rules up for single-instance environment, so I could add them to the installation guide? I would really appreciate it. Alternatively, you could add them to readme and make a pull request – I'd be happy to merge it.
Again, thanks for this great tool.
Environment settings:
Today I was checking my worker environment logs and in the nginx access logs I found some request that were made by external agents (not coming from sqs daemon process in localhost).
Show logs
After debugging I realized that this security problem is caused due to the security group I added to the worker environment (I made this on purpose to have access to the web env database - check this).
When you add a security group to an EC2 instance, the inbound rules that comes with it will be included as well. If your environment is a single instance environment (i.e. no load balancer involved) the security group of the web environment instance will contain the following inbound rule:
80 | TCP | 0.0.0.0/0
If you use that same security group for your worker, then everyone will be able to access it.
Note that in the case of a high availability environment (i.e. with load balancer), the inbound rule will limit traffic to the load balancer only, so in that scenario we won't have this security flaw.
I haven't tried this yet, but I think a better approach to the one described here is to edit the inbound rules of the RDS DB security group and add an entry for the worker instance security group. By doing that the database should accept connections from both environments and the worker should remain private always.
The text was updated successfully, but these errors were encountered: