Skip to content

Fix CVE-2017-11467: upgrade OrientDB 2.1.25 → 2.2.37#163

Draft
Copilot wants to merge 17 commits intomasterfrom
copilot/update-orientdb-version
Draft

Fix CVE-2017-11467: upgrade OrientDB 2.1.25 → 2.2.37#163
Copilot wants to merge 17 commits intomasterfrom
copilot/update-orientdb-version

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 17, 2026

Run 24614826683 on 309618da3f (the previous WAL-disable fix) showed the same O(N²) timing pattern (link 7s → relationships 19s → synchronisation_pooledSyncStage 66s → next class killed). So disabling WAL was not the actual remedy.

Real root cause

OrientDB 2.2.37 has STORAGE_MAKE_FULL_CHECKPOINT_AFTER_CLUSTER_CREATE = true by default. After every addCluster() call (i.e. every class/index creation), it performs a full storage checkpoint — fsync()'ing every cluster file plus the WAL. As clusters accumulate, each checkpoint scans/syncs all previously-created clusters, producing the classic O(N²) total cost. On Linux/macOS where fdatasync() is expensive, this turns ~30 schema classes into 5+ minutes; on Windows the same code is fast because NTFS batches writes.

Fix

In DBHelper.checkDB, additionally disable for the schema-setup window:

  • STORAGE_MAKE_FULL_CHECKPOINT_AFTER_CLUSTER_CREATE (the dominant cost)
  • STORAGE_MAKE_FULL_CHECKPOINT_AFTER_CREATE
  • STORAGE_MAKE_FULL_CHECKPOINT_AFTER_OPEN

Originals are captured before and restored in the existing finally block. The WAL flags and the comment block are kept — they were not harmful, just insufficient.

All three flag names verified to exist in OrientDB 2.2.x source (storage.makeFullCheckpoint{AfterCreate,AfterOpen,AfterClusterCreate}).

Tasks

  • Re-diagnose run 24614826683 — same O(N²) pattern, WAL fix alone insufficient
  • Identify true culprit — full-checkpoint-after-cluster-create runs after each addCluster
  • Disable STORAGE_MAKE_FULL_CHECKPOINT_AFTER_CLUSTER_CREATE (+ AFTER_CREATE / AFTER_OPEN) for schema setup; restore in finally
  • Verify on next CI run
Original prompt

Problem

CVE-2017-11467 is a critical vulnerability (CVSS 9.8) in OrientDB versions through 2.2.22. OrientDB does not enforce privilege requirements on where, fetchplan, and order by query features, allowing remote unauthenticated attackers to execute arbitrary OS commands via crafted requests.

The repository currently uses orientdb.version = 2.1.25 (defined in the root pom.xml at line ~119), which is vulnerable.

Required Fix

  1. In the root pom.xml, update the orientdb.version property from 2.1.25 to at least 2.2.23 (the first patched version). Prefer the latest 2.2.x release if possible.

  2. Also update orientdb.studio.version from 1.7.10 to a compatible version.

  3. Fix any compilation errors in the openidm-repo-orientdb module caused by API changes between OrientDB 2.1.x and 2.2.x. Key classes to check:

    • ODatabaseDocumentPool (may have been replaced by OPartitionedDatabasePool in 2.2.x)
    • OSimpleVersion
    • Any other deprecated/removed APIs in openidm-repo-orientdb/src/main/java/org/forgerock/openidm/repo/orientdb/impl/
  4. Update the legal/THIRDPARTYREADME.txt to reflect the new OrientDB version.

  5. Update documentation references to OrientDB version in openidm-doc/src/main/asciidoc/install-guide/chap-install.adoc if applicable.

The following is the prior conversation context from the user's chat exploration (may be truncated):

User: предложи исправление CVE-2017-11467

Assistant: ## CVE-2017-11467 в OpenIDM

Проблема: CVE-2017-11467 — критическая уязвимость (CVSS 9.8) в OrientDB, позволяющая удалённое выполнение произвольных команд ОС без аутентификации. OrientDB не проверяет привилегии при использовании where, fetchplan и order by в запросах, что позволяет выполнять Groovy-код через специально сформированные запросы.

Текущая версия в репозитории: orientdb.version = 2.1.25 (уязвимы все версии до 2.2.22 включительно).

Исправление

Необходимо обновить версию OrientDB до 2.2.23 или выше в корневом pom.xml:

<!-- Было: -->
<orientdb.version>2.1.25</orientdb.version>

<!-- Нужно: -->
<orientdb.version>2.2.23</orientdb.version>

Важно: Обновление с 2.1.x на 2.2.x — мажорный переход. Могут потребоваться:

  1. Проверка совместимости API — некоторые классы OrientDB (например, ODatabaseDocumentPool, OSimpleVersion) были изменены или удалены в 2.2.x. Нужно проверить компиляцию модуля openidm-repo-orientdb.
  2. Миграция данных — формат хранения OrientDB мог измениться между версиями.
  3. Обновление OrientDB Studio — текущая версия orientdb.studio.version = 1.7.10, её тоже следует обновить.

Хотите, чтобы я создал Pull Request с этим исправлением?

User: да

Assistant: I've started the process of creating a Pull Request to fix CVE-2017-11467 by upgrading OrientDB. The coding agent is now working on the changes — we're waiting for it to complete the PR. I'll share the link once it's ready.

This pull request was created from Copilot chat.

Copilot AI and others added 3 commits April 17, 2026 09:44
- Update orientdb.version from 2.1.25 to 2.2.37 in root pom.xml
- Update orientdb.studio.version from 1.7.10 to 2.2.37 in root pom.xml
- Remove OSimpleVersion import (removed in 2.2.x) from OrientDBRepoService.java
- Replace new OSimpleVersion(ver) with plain int ver in delete call
- Remove orientdb-enterprise dependency (merged into orientdb-core in 2.2.x)
- Update studio packaging in openidm-zip/pom.xml (remove distribution classifier,
  update ant pattern for renamed studio zip)
- Add --add-opens java.base/sun.nio.ch=ALL-UNNAMED for Java 17 + OrientDB 2.2.x
- Update OrientDB version in legal/THIRDPARTYREADME.txt
- Update OrientDB version in chap-install.adoc

Agent-Logs-Url: https://github.com/OpenIdentityPlatform/OpenIDM/sessions/e6262d96-e72c-4e30-ba23-7b7f86383e93

Co-authored-by: vharseko <6818498+vharseko@users.noreply.github.com>
Copilot AI changed the title [WIP] Update OrientDB version to 2.2.23 and fix compilation errors Fix CVE-2017-11467: upgrade OrientDB 2.1.25 → 2.2.37 Apr 17, 2026
Copilot AI requested a review from vharseko April 17, 2026 09:50
…or OrientDB 2.2.37

OrientDB 2.2.37's OByteBufferPool uses reflection to access sun.nio.ch.DirectBuffer
on Java 9+, causing InaccessibleObjectException and OSGi bundle startup failure
without this JVM flag.

Agent-Logs-Url: https://github.com/OpenIdentityPlatform/OpenIDM/sessions/c25be698-8b4d-4aa8-90b7-5e7383c1edda

Co-authored-by: vharseko <6818498+vharseko@users.noreply.github.com>
…entdb-core 2.2.37

OrientDB 2.2.37's orientdb-core OSGi bundle has a mandatory Import-Package for
javax.annotation.meta. The jsr305-3.0.2.jar is a proper OSGi bundle (with
Export-Package: javax.annotation.meta;version=3.0.2) and satisfies this
dependency, fixing the bundle resolution failure at startup.

Agent-Logs-Url: https://github.com/OpenIdentityPlatform/OpenIDM/sessions/9e4dae20-6edb-4e09-b8a0-a55afa3a268d

Co-authored-by: vharseko <6818498+vharseko@users.noreply.github.com>
1. Fix Windows path bug in EmbeddedOServerService.java: use
   dbURL.substring(indexOf(':') + 1) instead of split(":")[1] so that
   Windows paths like plocal:D:/a/.../db/openidm are parsed correctly.
   The old code returned just "D" (the drive letter), making ORIENTDB_HOME
   resolve to <openidm_dir>\D rather than the real DB path.

2. Set ORIENTDB_HOME to the OpenIDM working directory (not the DB
   directory). OrientDB 2.2.37 resolves ${ORIENTDB_HOME}/config/security.json
   using the ORIENTDB_HOME system property.

3. Add openidm-zip/src/main/resources/config/security.json with minimal
   content. OrientDB 2.2.37's ODefaultServerSecurity.loadConfig() logs a
   SEVERE (→ ERROR via JUL-to-SLF4J bridge) when security.json is absent.
   The CI checks (! grep "ERROR" openidm0.log.0 on Linux;
   find /c '"ERROR"' | findstr "0" on Windows) both fail on that ERROR.
   Providing the file prevents the SEVERE from being logged.

Agent-Logs-Url: https://github.com/OpenIdentityPlatform/OpenIDM/sessions/a183a4b3-cd51-4122-be8c-24826ee2caec

Co-authored-by: vharseko <6818498+vharseko@users.noreply.github.com>
Copilot AI and others added 2 commits April 17, 2026 13:37
OrientDB 2.2.37 calls fdatasync() after every cluster/schema
change via STORAGE_CONFIGURATION_SYNC_ON_UPDATE (default true) and
on every WAL page flush via WAL_SYNC_ON_PAGE_FLUSH (default true).

As the schema grows with each new class, the storage-config rewrite
becomes progressively larger:
- Each addCluster() rewrites the full cluster list and calls fsync()
- N classes = O(N²) total I/O work

On Linux, fdatasync() is much slower than on Windows (Windows uses
async I/O that batches writes). With 30 OrientDB classes to create,
this turned the initial schema initialization into a 3+ minute
operation, exceeding the CI 3-minute timeout.

Fix: temporarily set both flags to false for the duration of
populateSample(), then restore the originals in a finally block.
This makes schema creation as fast on Linux as on Windows while
preserving full durability guarantees for all normal operations.

Agent-Logs-Url: https://github.com/OpenIdentityPlatform/OpenIDM/sessions/24ca770d-f1c1-4b56-bdfb-08182ce5f0a1

Co-authored-by: vharseko <6818498+vharseko@users.noreply.github.com>
Copilot AI and others added 2 commits April 17, 2026 14:17
The previous fix (moving STORAGE_CONFIGURATION_SYNC_ON_UPDATE and
WAL_SYNC_ON_PAGE_FLUSH into populateSample) was insufficient because
both flags are applied AFTER the storage is opened.  The background
WAL flush thread (OWriteAheadLog) starts at storage-open time and
calls fdatasync() every WAL_COMMIT_TIMEOUT ms (default 1 s) on a
WAL that grows with each new cluster.  This background flush is not
gated by WAL_SYNC_ON_PAGE_FLUSH, so the O(N²) behaviour persisted.

Root cause: USE_WAL is read once when OLocalPaginatedStorage is
created.  It must therefore be set to false BEFORE db.create() to
prevent the WAL and its background flush thread from being started
at all.

Changes:
- Move all OGlobalConfiguration tuning into checkDB(), before the
  ODatabaseDocumentTx object is used (db.exists() only probes, no
  storage is opened at that point).
- For a new DB (!exists): also set USE_WAL=false so no WAL is
  created.  The storage is closed cleanly at the end of checkDB
  (dirty-page flush by the disk cache), leaving a consistent state
  for the subsequent pool open which restores USE_WAL=true.
- For an existing DB: keep WAL intact; only suppress the config-sync
  and WAL-page-flush flags so crash recovery is preserved.
- Simplify populateSample(): remove the now-redundant
  OGlobalConfiguration manipulation added in the previous commit.

Agent-Logs-Url: https://github.com/OpenIdentityPlatform/OpenIDM/sessions/0d744d44-9f47-4fc9-a96b-7e4b970b4405

Co-authored-by: vharseko <6818498+vharseko@users.noreply.github.com>
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.

2 participants