Skip to content

Conversation

@puck
Copy link

@puck puck commented Sep 30, 2025

If debugging is enabled, the password used to authenticate jsonrpc calls is logged.

This PR also fixes deepcopy being called on every jsonrpc call.

Fixes #70.

Andrew Ruthven added 2 commits September 30, 2025 19:06
Blank out the password.

Fixes: OCA#70

To test I modified odoorpc/tests/__init__.py and added:

import logging
logging.basicConfig()
logger = logging.getLogger('odoorpc')
logger.setLevel(logging.DEBUG)
The logic here is a bit expensive on CPU, and only need it if debug
logging is enabled.
@puck
Copy link
Author

puck commented Oct 3, 2025

Okay, so this has been approved two days ago. How does it get merged and a fixed release cut?

@pedrobaeza
Copy link
Member

@puck
Copy link
Author

puck commented Oct 5, 2025

Can a @OCA/core-maintainers please review this PR?

Comment on lines +57 to +60
# The password is the 3rd element of the args array.
if 'args' in data['params']:
if 2 in data['params']['args']:
log_data['params']['args'][2] = "**********"

Choose a reason for hiding this comment

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

I think, reading this line args is a list, not a dict, can you confirm?

>>> test = ["a", "b", "c"]
>>> 2 in test
False
>>> test[2]
'c'

It could be nice to add a unit test of this use case ?

As this is a proxy, I guess there are other method going over this method that could be legitimate logged. I would suggest something likes

Suggested change
# The password is the 3rd element of the args array.
if 'args' in data['params']:
if 2 in data['params']['args']:
log_data['params']['args'][2] = "**********"
# The password is the 3rd element of the args array.
if 'args' in data['params'] and data['params'].get("method") == "login":
if len(data['params']['args']) >= 3:
log_data['params']['args'][2] = "**********"

you may check common service as well I suppose ?!

Copy link
Collaborator

Choose a reason for hiding this comment

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

I agree, method accepting passwords have to be checked 👍

Copy link
Collaborator

@sebalix sebalix Oct 13, 2025

Choose a reason for hiding this comment

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

Details: the password is sent on every call sadly on /jsonrpc endpoint, both for the initial login (from common service) and then through execute (from object service).
So I would hide the password if the endpoint URL is /jsonrpc for common and object service. And regarding the db service, we could keep things simple: hide all the args params (which contain super-admin password, database name etc).
There is also the report service but it's not working since Odoo 11.0, not sure we should try to handle it.

Copy link
Author

Choose a reason for hiding this comment

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

This sounds very sensible. Personally I only ever use the web interface of Odoo and have no knowledge of the APIs other than tracking this issue internally at work once we discovered it.

I am totally fine with this PR being replaced by a more comprehensive fix.

@simahawk
Copy link

@sebalix ping

@sebalix sebalix added this to the v0.10.1 milestone Oct 13, 2025
for log purpose.
"""
log_data = data
log_data = copy.deepcopy(data)
Copy link
Collaborator

@sebalix sebalix Oct 13, 2025

Choose a reason for hiding this comment

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

The idea to defer the deep copy later in the code was to avoid it if nothing needed to be hidden.

If we are sending a huge payload (like a DB dump through db.restore, or product images), copying it in memory with deepcopy will consume twice the memory.

Your issue has to be address anyway, we cannot keep passwords in clear in logs.

Copy link
Collaborator

Choose a reason for hiding this comment

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

That said, maybe for debug purpose, it's OK to go this way

Copy link
Author

Choose a reason for hiding this comment

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

Yeah, this is why I added the guard to only call this function if debug mode is enabled.

Copy link
Author

Choose a reason for hiding this comment

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

I moved the deepcopy as I was originally removing the password and then the RPC call was failing. :)

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.

Password is logged in clear text

5 participants