← 返回列表
全部 Skill›测试与安全 Testing & Security›odoo-security

odoo-security

作者 @odoo · 语言 en
Security audit of Odoo addon code: access control (ir.access, field groups, sudo), injection (SQL, domain, eval, XSS via Markup/markup()), untrusted public methods/RPC, controller auth/CSRF, file access, deserialization, returning complex objects, getattr/setattr, timing attacks. Use when auditing an addon, or judging whether a specific construct (a sudo, raw SQL, a route, ...) is safe.
测试与安全 Testing & Security安全通用执行命令读写文件敏感路径待翻译
存储库
最近源活动
—
检测 SKILL.md 语言
en
星标 ★
54,578
分支 Fork
0
安装选项
提示
指令
使用 AI 助手安装
将下面的提示复制到你正在使用的 AI 助手中。
下载完整 Skill 目录(含全部配套文件)。 下载压缩包 ↓
SKILL.md 原文预览

Security audit of Odoo code

Audit Odoo addons for the framework-specific ways access control and injection

go wrong. When a feature needs more access than the rules give, it gets the

minimum, in the narrowest scope, with a comment saying why; a silent widening

(a bare sudo(), a loosened access row) is a finding.

Process

  • Review the security/ data files against Access control.
  • Sweep the addon for every pattern in the table below; judge each hit against

its section. A hit is not a finding by itself; the sections say what makes

it one.

  • Report each finding with severity, exact file/line, and a minimal fix.

The audit is complete when every pattern has been swept and every hit judged.

| Sweep for | Judge against |

| --- | --- |

| sudo(, with_user(, with_company( | Don't over-sudo |

| cr.execute, SQL(, .format/%/f-string near SQL | Use the ORM; parameterize SQL |

| domain built from request, RPC, or stored field values | Domain injection |

| public (non-_) model methods | Default to private methods |

| @http.route(, bare @route( | Routes: auth, POST, CSRF |

| innerHTML, insertAdjacentHTML, markup( (JS), Markup( (Python), t-raw (dead code) | Prevent XSS |

| password/token/secret fields | Field-level access |

| related= crossing models (sudo-computed by default) | Field-level access |

| open( | Open files with file_open |

| eval(, exec(, safe_eval | eval is evil |

| pickle | Never pickle |

| getattr(, setattr( on records | getattr/setattr |

| == comparing a secret/token | Timing attacks |

| def f(..., x=[]) / x={} | Mutable default arguments |

| methods returning rich objects | Don't return complex objects |

| a check on vals in def create( before super().create( | Access control |

Access control

Mechanics of ir.access rows and field groups are in the odoo-guidelines

skill (Access rights,

Fields); audit security/ with

the attacker's reading:

  • Flag any c/u/d operation granted to base.group_everyone,

base.group_portal, or base.group_public; scrutinize even r on models

holding personal or business-sensitive data.

  • A permission row's operation set is what it grants; a *restriction*

(group-less) row covering only some operations leaves the others governed by

the permission rows alone: if any permission grants write, an attacker

can alter records the read restriction hides (write checks write access

only, never read). Cover all CRUD operations that need restricting.

  • Multi-company models need a company restriction row; sensitive models need

domain restrictions, not just group permissions.

  • A create override that validates vals before super().create(), for

instance to restrict some fields or values to a group, can be bypassed when

it reads only vals. The ORM adds values after that code, in

_prepare_create_values, called by BaseModel.create:

  • the default_<field> keys of the context: a caller who is refused

book_id in vals passes default_book_id in the context instead;

  • the ir.default records: an internal user can add their own;
  • what an override of default_get adds, and the precomputed fields.
  • To prevent this, move the check to an override of _prepare_create_values

and check what its super() returns: the check still runs before the

record is created. Those values already hold the context defaults and the

ir.default ones, so there is no need to handle them by hand.

  • A raise after super().create() is too late: the record is created

already, so if the caller catches the AccessError, the creation is not

reverted.

  • In _prepare_create_values, the values also hold the default= of the

field. A check that only tests that a value is there, as

if vals.get('book_id'):, then also refuses a create where the caller gave

no book_id and the field has a default. Check which book the value is

(may the user set that one?), not whether the key is there.

  • write has no such gap: it adds no default.

Field-level access

  • A field's groups attribute removes it from views and fields_get and

raises on explicit read/write. Use it for sensitive fields instead of

relying on the UI to hide them.

  • Passwords and API tokens: restrict them with groups="base.group_system",

or groups=fields.NO_ACCESS to hide the field from everyone, admins

included. A token field on a model with a permissive access row is readable

by any user via search_read.

  • related fields are sudo-computed by default (related_sudo=True): a

related field reaching sensitive data through a user-writable Many2one

lets the user point the M2o at an arbitrary record and read the related

value with elevated rights; set related_sudo=False on sensitive chains.

(readonly=False write-through is a separate concern: it runs in the

user's environment and is access-checked.)

Default to privat

评论
Oodoo
odoo
odoo/odoo
查看 GitHub 仓库 查看作者的其他 Skill
来源信息
作者@odoo
所属大类测试与安全 Testing & Security / 安全
国内可用性通用
最近源活动—
风险提示执行命令、读写文件、敏感路径
提示:风险标签为程序静态扫描结果,仅作提示,不代表安全认证。安装前请阅读 SKILL.md 及其引用的脚本、权限,自行判断是否可信。