Skip to content

security(demo): deactivate default-credential demo users on production install + drop Production/Stable#341

Draft
gonzalesedwin1123 wants to merge 6 commits into
19.0from
security-demo-default-credentials-stable
Draft

security(demo): deactivate default-credential demo users on production install + drop Production/Stable#341
gonzalesedwin1123 wants to merge 6 commits into
19.0from
security-demo-default-credentials-stable

Conversation

@gonzalesedwin1123

@gonzalesedwin1123 gonzalesedwin1123 commented Jul 24, 2026

Copy link
Copy Markdown
Member

Problem

The demo bundles ship active res.users with the well-known, documented password demo in their
data section (loaded on every install, not gated on demo mode):

  • spp_demo/data/users_data.xmldemo_viewer / demo_officer / demo_supervisor / demo_manager,
    and sppadmin in spp_security.group_spp_admin (SPP admin).
  • spp_farmer_registry_demo/data/demo_users.xml — re-roles the above and adds
    demo_user_cr_local_validator / _cr_hq_validator / _program_manager / _cycle_approver
    (all password demo).

Both modules were marked development_status: "Production/Stable" and installable: True. That
production-readiness signal invites an operator to install a demo bundle on a real deployment;
installation then creates the default-credential accounts, and on an internet-facing instance an
unauthenticated attacker can try the documented credentials and gain access (up to SPP admin).

spp_demo is the systemic root — every demo bundle depends on it and re-uses its users. Severity:
medium
(requires installing a *_demo module in production, which the status signal encourages).

Fix

Defense-in-depth at the point the accounts would become dangerous, plus removing the misleading signal:

  • post_init_hook on spp_demo (shared helper deactivate_default_demo_users) and
    spp_farmer_registry_demo: when the database has no demo data (a production-style install), the
    default-credential users are archived (active=False) so their known password cannot log in.
    On a demo/evaluation database (demo data enabled) they are left active, so demos and the
    generators (which env.ref these users) are unaffected. Demo-enabled is detected via
    ir.module.module.demo.
  • development_status lowered Production/StableAlpha on both modules, and a DEMO ONLY … never install on a production/internet-facing instance warning added to each summary.

This keeps the users in the data section (no load-order/behavioral churn); the idiomatic
datademo restructure across the whole demo family is filed as a follow-up.

Tests

Test-first (red → green). New test_demo_user_safety.py in each module:

  • default-credential users are archived when demo is disabled (demo_enabled=False);
  • users stay active when demo is enabled (no regression for demos/generators);
  • neither module is marked Production/Stable.

./spp t spp_demo0 failed of 124; ./spp t spp_farmer_registry_demo0 failed of 135
(existing generator tests that reference the demo users stay green — test DBs load demo data). No
existing tests removed or modified.

Scope / notes

  • Version collision: the in-flight force-unlock PR security(programs): enforce system-admin authorization on Force Unlock #336 already bumps spp_farmer_registry_demo
    to 19.0.2.1.2; this PR uses 19.0.2.1.3 (no logic conflict — security(programs): enforce system-admin authorization on Force Unlock #336 edits the generator).
    Whoever merges second re-conflicts on manifest/HISTORY/README (trivial re-merge).
  • Follow-up (to file): other demo bundles (spp_mis_demo_v2, spp_grm_demo, spp_case_demo)
    carry the same Production/Stable + data-section demo users; and the idiomatic datademo
    restructure across the family. Scoped out here to keep this PR reviewable and matching the report.
  • README.rst / static/description/index.html for both modules to be regenerated from CI's pinned generator.

Merge order

Per the cross-PR interaction analysis (2026-07-24, internal/plans/security-prs-interaction-analysis.md): merge after #336 on spp_farmer_registry_demo — this PR's 19.0.2.1.3 already reserves .1.2 for #336, and its HISTORY entry assumes that sequence. Re-merge this branch when #336 lands (metadata-only conflict: manifest/HISTORY/README). No semantic interaction: this PR's user archiving only runs on no-demo-data DBs where the generator doesn't run, env.ref still resolves archived users, and the approval loop has a sudo fallback.

… install

Add safety tests for spp_demo and spp_farmer_registry_demo: the default-
credential users (shared password 'demo', incl. sppadmin) must be archived
when demo data is disabled (production-style install) and left active when
demo data is enabled, plus a guard that neither module is marked
Production/Stable.
…n install

The demo bundles ship active res.users with the well-known password 'demo'
(including sppadmin with SPP admin rights) in their data section, so the
accounts are created on every install. Marked Production/Stable, the modules
signalled production-readiness, so an operator could install a demo bundle on
an internet-facing instance and expose those default credentials to login.

Add a post_init_hook to spp_demo (shared helper) and spp_farmer_registry_demo
that archives the default-credential users when the database has no demo data
(a production-style install); on demo/evaluation databases the users stay
active so demos and generators are unaffected. Also lower development_status
from Production/Stable to Alpha and add a DEMO-ONLY warning to each summary.
spp_demo 19.0.2.1.0 -> 19.0.2.1.1; spp_farmer_registry_demo 19.0.2.1.1 ->
19.0.2.1.3 (skips .1.2 taken by the in-flight force-unlock PR #336 on the
same module). README.rst / index.html regenerated from CI's pinned generator.
@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@codecov

codecov Bot commented Jul 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 69.30%. Comparing base (1caf794) to head (13d0482).
⚠️ Report is 3 commits behind head on 19.0.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             19.0     #341      +/-   ##
==========================================
- Coverage   74.28%   69.30%   -4.99%     
==========================================
  Files         372      148     -224     
  Lines       25385    14131   -11254     
==========================================
- Hits        18857     9793    -9064     
+ Misses       6528     4338    -2190     
Flag Coverage Δ
spp_analytics ?
spp_api_v2_cycles ?
spp_api_v2_entitlements ?
spp_api_v2_gis ?
spp_api_v2_programs ?
spp_api_v2_simulation ?
spp_audit_programs ?
spp_base_common 91.07% <ø> (+0.80%) ⬆️
spp_case_demo 94.75% <ø> (+0.41%) ⬆️
spp_case_entitlements ?
spp_case_programs ?
spp_cr_type_assign_program ?
spp_dci_compliance ?
spp_dci_demo 94.28% <ø> (+0.88%) ⬆️
spp_dci_server_social ?
spp_demo 74.12% <100.00%> (+0.49%) ⬆️
spp_demo_phl_luzon 86.71% <ø> (+0.60%) ⬆️
spp_drims ?
spp_drims_sl ?
spp_drims_sl_demo ?
spp_farmer_registry_demo 61.23% <100.00%> (+0.21%) ⬆️
spp_gis_report ?
spp_grm_demo 81.43% <ø> (+1.56%) ⬆️
spp_indicator ?
spp_indicator_studio ?
spp_metric_service ?
spp_mis_demo_v2 70.99% <ø> (+0.03%) ⬆️
spp_programs 65.27% <ø> (+<0.01%) ⬆️
spp_registry 86.94% <ø> (+0.10%) ⬆️
spp_security 69.56% <ø> (+2.89%) ⬆️
spp_simulation ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
spp_demo/__init__.py 100.00% <100.00%> (ø)
spp_farmer_registry_demo/__init__.py 100.00% <100.00%> (ø)

... and 226 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Generated files applied verbatim from CI's pinned oca-gen-addon-readme output
for spp_demo (19.0.2.1.1) and spp_farmer_registry_demo (19.0.2.1.3).
…oupling

From staff review: the helper tests hard-coded demo_enabled, leaving the
load-bearing demo_data_enabled() detection and the manifest hook wiring
untested. Add assertions that demo_data_enabled matches the module's real
demo flag and that both manifests register post_init_hook. Also document in
users_data.xml that the archived-user safety depends on these records
carrying no active field (the hook runs on install only).
@gonzalesedwin1123

Copy link
Copy Markdown
Member Author

Staff review (verdict SHIP) — folded in the MEDIUM test-coverage gap (assert demo_data_enabled matches the module demo flag + manifest wires post_init_hook) and a LOW hardening comment in users_data.xml (archived-user safety depends on no active field, hook runs on install only). Systemic follow-up for the other demo bundles filed as #345 (spp_mis_demo_v2/spp_grm_demo/spp_drims_sl(_demo) unguarded + data->demo restructure).

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.

1 participant