Take the 2-minute tour ×
Information Security Stack Exchange is a question and answer site for Information security professionals. It's 100% free, no registration required.

I'm building a JavaFX 2.0 standalone application (it'll be distributed as an .exe) and it opens a connection to a MongoDB instance. The connection is just a standard Mongo connection using the Mongo wire protocol.

Is the Mongo wire protocol secure enough, or could users examine it to see the data being passed back and forth?

Mongo database connections will be able to use SSL at some point in the future, but that isn't available yet.

Instead, should I use a REST web service for data access with SSL? The direct database connection is quite a bit faster so it would be great if I could keep that, but also not have big security problems.

Thanks.

share|improve this question
    
Unless you want to give your end users direct access to the database you need an API in front of mongo anyways. SSL won't protect you from a malicious endpoint. –  CodesInChaos Oct 22 '13 at 16:41

1 Answer 1

up vote 4 down vote accepted

Just for your information. Giving a direct database connection in a client side application is a bad idea. Build a RESTful interface which allows for correct authentication and input validation. This will allow you to have a stricter control on what your applications can access.

The problem is that currently MongoDB doesn't offer SSL encapsulation. This means that in itself, the wire protocol can be eavesdropped upon (the data sent over the protocol is exposed). So if you are running this protocol non-locally (so across a network) then yes it's not secure, but not because the protocol itself is insecure, but because the implementation currently can't guarantee confidentiality or integrity due to the lack of encapsulation.

However you can fix this by encapsulating the protocol yourself. If the protocol doesn't offer SSL you first make a tunnel and send the protocol through that tunnel. For instance you make an encrypted VPN between your webserver and MongoDB and through this VPN you send the wire protocol connection (note that you should use a secure VPN protocol). Preferably this is implemented so that you have end-point encryption.

This will disallow eavesdroppers from sniffing your wire connection.

share|improve this answer
    
Totally agree with this answer. Just want to reiterate the importance of implementing a RESTful interface. This stands even if in the future Mongo allows SSL connections. SSL only protects the data in transit; a correctly implemented RESTful application will protect against malicious application users. –  paj28 Oct 22 '13 at 17:31

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.