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

Keychain: account manager for external systems #644

Merged
merged 23 commits into from
Feb 10, 2017

Conversation

hparfr
Copy link
Contributor

@hparfr hparfr commented Dec 12, 2016

See readme for more info

@oca-clabot
Copy link

Hey @hparfr, thank you for your Pull Request.

It looks like some users haven't signed our Contributor License Agreement, yet.
You can read and sign our full Contributor License Agreement here: http://odoo-community.org/page/website.cla
Here is a list of the users:

  • Raph (no github login found)

Appreciation of efforts,
OCA CLAbot

@lasley
Copy link
Contributor

lasley commented Dec 12, 2016

This is very dangerous IMO & I am explicitly 👎

This is enforcing bad practice and the entire keychain can be easily compromised in the UI with code similar to the following:

model = env['keychain.account']

log(
    str(env['keychain.account'].search([]).read()),
)

Given the current security, it wouldn't even require an admin to run this exploit.

There is also no way to expire the existing key in the event of compromise, which is a 100% necessity with anything encryption.

I'm sorry that I am not providing anything helpful to this PR, but this is because we have been toiling over this for a while & have not been able to come up with a production viable solution at this point.

I would not trust my data with either this module or the PoCs we have already built for this purpose, thus the 👎 . Security is no joke, and a simple disclaimer is not enough IMO.

@hparfr
Copy link
Contributor Author

hparfr commented Dec 14, 2016

Again, the aim of this module is to store credentials like smtp server, carriers, market places, magento, ftp servers and so on and don't leak them with db dumps or search_read.

It's credentials you need in odoo and it's credentials which are currently stored in plain text by the modules and are easily recoverable with your snippet.

With keychain module, at runtime you need to do 2 actions to decrypt a password :

  • get the record from the ORM (which is filtered with odoo's ACL)
  • get the key from the config manager (which is only accessible by python)

From a security point of view : the current state with odoo out of the box is very terrible. With this keychain module, it's certainly not perfect but a little more secure.

This is enforcing bad practice

Which one ?

and the entire keychain can be easily compromised in the UI with code similar to the following:

No with keychain supported modules you will get :

  • if you are not in authorized group : access_error
  • else : an encrypted password

With other modules, you will get :

  • if you are not in authorized group : access_error
  • else : a clear text password

There is also no way to expire the existing key in the event of compromise, which is a 100% necessity with anything encryption.

In the event of a compromise you have to change all your passwords.
If you want key expiration or x509 certificates your PR is welcome :) I hope the current design of this module allows this kind of enhancement.

but this is because we have been toiling over this for a while & have not been able to come up with a production viable solution at this point.

It seams your requirements (storing credit card or personal / medical data) are very different.
You need conform to norms (like PCI-DSS) and your responsibility may be engaged if you leak this kind of data : this is not the aim of this module.

@hparfr
Copy link
Contributor Author

hparfr commented Dec 14, 2016

Responding to comments on #622 (comment)

This module will be available on the App Store. I can guarantee that it will be installed on production servers by administrators that did not read the disclaimer in the ReadMe.

This module is unusable / useless if no modules consumes his services. I hope, the developer who add this module as a dependecy of his own module will read the readme. If he don't (which is plausible) we can't do anything about it.

I do also like the idea of a separate service. I created a Golang app recently to do some key management & other useful things, and have been thinking of integrating it into Clouder

It's a good idea to externalize the storage of sensitive data, but it may be overkill to store smtp credentials or delivery carrier accounts.

Say no to everyone
@rvalyi
Copy link
Member

rvalyi commented Dec 14, 2016

@hparfr @lasley I won't comment about the module because I'm not a security expert. That being said, usually a good way to inject secrets in an app is via environment variables.

These can be managed with tools such https://www.vaultproject.io if something more high level than editing these secrets over ssh is required.

Raph added 4 commits December 14, 2016 14:13
Add multikey feature
fix tests
update doc
Copy link
Contributor

@lasley lasley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rvalyi - Ohhhhh I like that. I'm going to see about making a connector for VaultProject after I play around with it a bit more.

@hparfr - I agree on the need, but this is adding a tad bit of security and also the possibility of mass data corruption if the key needs to be revoked. The tradeoff is more dangerous than it is worth IMO.

Obviously the community can override my feelings, but they are firm on this. My project was doing nearly the exact same things you are here & I abandoned it because it is flawed from the ground up.

I recommend reading into OWASP guidelines on these subjects. They explain it all much better then me, and you will notice that nearly nothing of the guidelines is covered.

Again, I agree it isn't covered in Odoo either, but you are specifically advertising this module as a keychain. That name implicitly states you are managing the keys in a safe fashion.

@hparfr
Copy link
Contributor Author

hparfr commented Dec 16, 2016

Thanks @lasley for having taking time to expose your arguments.

@lasley
Copy link
Contributor

lasley commented Dec 16, 2016

@hparfr - I honestly feel real bad about blocking this & am trying to come up with a viable solution for the key management + a proposal to make this more secure. I'll update you.

@bealdav
Copy link
Member

bealdav commented Dec 21, 2016

Hi @lasley,

Ok there are more secure ways with external and complex system, but our all customers can't pay to have an erp (aka all in one features system) and 36 connectors with external system to maintain over the time.
It depends of criticity of these keys

@hparfr proposal use a secure way, I think

Fernet is built on top of a number of standard cryptographic primitives. Specifically it uses:

   AES in CBC mode with a 128-bit key for encryption; using PKCS7 padding.
   HMAC using SHA256 for authentication.
   Initialization vectors are generated using os.urandom().

It ensures all password are not clear text.

It's a v9 module. If in v10 or v11 you provide a better way to do it, then we'll migrate to the new solution, but please don't break continuous improvement of the community, it's a step in the right direction

https://en.wikipedia.org/wiki/Continual_improvement_process

👍

@lasley
Copy link
Contributor

lasley commented Dec 21, 2016

@bealdav - This isn't simply about security. This is also about potential data destruction with no avenue of resolve. Encryption isn't just flipping a few bits, then flipping them back with the appropriate key when needed - you also need to build a way for re-encryption of data against new keys & the revocation of old. This is standard in any application that encrypts anything, and any product without it is dangerous. Continuous improvement does not help the user of the application in the middle of a breach scenario that is faced with the decision of having to destroy all their encrypted data in order to revoke a key. Revocation is not a feature of an encryption system, it is a requirement.

@bealdav
Copy link
Member

bealdav commented Dec 21, 2016

@lasley If security was the main point, you'd haven't choose odoo at all, don't you think ?
Here it's better secure than odoo standard practice. Nowdays any module store its password with no rule, some time in clear text.
Rome was not built in one day and here it's v9, an old version, now.
Improvement will comes after in v10
You can propose a feature to provide revocation, no problem.
@hparfr could you consider to add revocation in roadmap ?

@lasley Thanks for your contribution on security subjects. It's a real important for us to have expert like you on this matter, just let community go step by step to real good practice as you suggest.

@legalsylvain
Copy link
Contributor

Hi,
I'm not expert in the security domain, but I find the design of this module very good. To steal uncrypted credentials you have to have access to the database AND the config openerp file. So I see it as something secured.
Maybe there are other possibilities, but for the time being, this is a good solution, and better than nothing, specially because there are actually some OCA / not OCA modules with clear credentials (not secure), or others with clear token (not very secure) so 👍 for the concept.

@bealdav said :

It's a v9 module. If in v10 or v11 you provide a better way to do it, then we'll migrate to the new solution, but please don't break continuous improvement of the community, it's a step in the right direction

👍 on that point, too.

@OCA/board , @StefanRijnhart, @Others, could you give your PoV ?

kind regards.

@bealdav
Copy link
Member

bealdav commented Dec 22, 2016

ping @guewen @yvaucher

Raph added 2 commits January 3, 2017 14:51
Fix rst in readme
Rename _set_password to _inverse_set_password in models and tests
Add missing new line in ir.model.access
Update version number to 9.xx
@mourad-ehm
Copy link
Contributor

👍 because this module make one step in the right direction. It brings a solution to managing credentials for external applications which not exist now in odoo.

@hparfr
Copy link
Contributor Author

hparfr commented Jan 31, 2017

Thanks @elicoidal for your precise review.

@hparfr hparfr changed the title [WIP] Keychain: account manager for external systems Keychain: account manager for external systems Feb 3, 2017
@hparfr
Copy link
Contributor Author

hparfr commented Feb 3, 2017

Requested changes taken in account.
This PR is now ready to be merged.

Thanks everyone for your comments and reviews.

@hparfr
Copy link
Contributor Author

hparfr commented Feb 8, 2017

What may I do for this PR to be accepted ?

  • fixed requested changes
  • tests ok

@bealdav
Copy link
Member

bealdav commented Feb 8, 2017

ping @elicoidal @lasley

@lasley
Copy link
Contributor

lasley commented Feb 8, 2017

Sorry but I cannot sign off with this potential for data loss. A PSC will need to dismiss my review for merge. There's definitely enough thumbs though and it sounds like @elicoidal was onboard with the risk, so you should be good here soon.

@elicoidal
Copy link

Can you check travis?
Can you add in the readme a disclaimer/warning with a link to this discussion?

Link to PR
@hparfr
Copy link
Contributor Author

hparfr commented Feb 9, 2017

Travis is failing on other modules when database_cleanup is included
https://travis-ci.org/OCA/server-tools/builds/199916286

@lasley
Copy link
Contributor

lasley commented Feb 9, 2017

@hparfr - The build was fixed in #719, so you should be able to clear the issue here with a rebase on the current 9 🚀

Revert config at its previous state.
@sebastienbeau sebastienbeau merged commit 4991c06 into OCA:9.0 Feb 10, 2017
sebastienbeau pushed a commit to akretion/server-tools that referenced this pull request Feb 13, 2017
sebastienbeau pushed a commit to akretion/server-tools that referenced this pull request Feb 13, 2017
mstuttgart pushed a commit to multidadosti-erp/server-tools that referenced this pull request Apr 20, 2017
andhit-r pushed a commit to open-synergy/server-tools that referenced this pull request Jul 26, 2017
andhit-r pushed a commit to open-synergy/server-tools that referenced this pull request Jul 26, 2017
andhit-r pushed a commit to open-synergy/server-tools that referenced this pull request Jul 29, 2017
andhit-r pushed a commit to open-synergy/server-tools that referenced this pull request May 18, 2018
andhit-r pushed a commit to open-synergy/server-tools that referenced this pull request May 20, 2018
andhit-r pushed a commit to open-synergy/server-tools that referenced this pull request Sep 6, 2018
andhit-r pushed a commit to open-synergy/server-tools that referenced this pull request Sep 6, 2018
andhit-r pushed a commit to open-synergy/server-tools that referenced this pull request Oct 4, 2019
tglukhov pushed a commit to invitu/server-tools that referenced this pull request Mar 27, 2020
modoolar-bot pushed a commit to modoolar/oca-server-tools that referenced this pull request Jan 14, 2022
SiesslPhillip pushed a commit to grueneerde/OCA-server-tools that referenced this pull request Nov 20, 2024
Syncing from upstream OCA/server-tools (13.0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants