Skip to content

fix(deps): migrate vendored dav lib from xmldom to @xmldom/xmldom - #775

Merged
phil-davis merged 1 commit into
masterfrom
fix/xmldom-security-migration
Jul 6, 2026
Merged

phil-davis merged 1 commit into
masterfrom
fix/xmldom-security-migration

Conversation

@DeepDiver1975

Copy link
Copy Markdown
Contributor

What

Migrate the vendored WebDAV/CalDAV/CardDAV client (js/dav) from the abandoned
xmldom package to its maintained successor @xmldom/xmldom (^0.8.13).

Why

[email protected] carries 1 critical + 5 high Dependabot advisories on the
runtime dependency, all with no patch available on the xmldom line
(vulnerable range <= 0.6.0, first_patched_version: none). The project was
renamed to @xmldom/xmldom, where these are fixed. This clears the runtime
security alerts blocking the app for the ownCloud 11 release.

Changes

  • js/dav/lib/parser.js — require('@xmldom/xmldom') instead of 'xmldom'.
    The only usage is new DOMParser().parseFromString(str, 'text/xml'), whose
    API is identical across both packages.
  • js/dav/package.json — swap the dependency (@xmldom/xmldom ^0.8.13).
  • js/dav/lib/debug.js — export via module.exports (was export default)
    so the module resolves under a modern bundler. Behaviour is unchanged
    (debug(topic)(message)); all seven require('./debug') call sites and the
    one import debug from './debug' continue to work.
  • js/dav/dav.js — regenerated browser bundle.

Note on the bundle rebuild

dav.js is a prebuilt browser bundle. The original toolchain
(browserify@11 / babel@5, ~2015) no longer installs on current npm, so the
bundle was rebuilt with esbuild (IIFE, global dav, browser platform).

Verification performed:

  • The exported dav API is identical to the previous bundle — 36 exports,
    version 1.8.0 (diffed programmatically).
  • @xmldom/xmldom round-trips a CalDAV/CardDAV multistatus document through
    the parser.js code path.
  • No require('xmldom') remains in the shipped bundle.

The large dav.js diff is entirely the regenerated bundle; the reviewable
change is the three source files above.

The vendored WebDAV/CalDAV/CardDAV client under js/dav bundled the
abandoned `xmldom` package (0.1.x), which carries a critical and several
high-severity advisories with no fix available on that release line
(vulnerable range <= 0.6.0, patched: none). The package was renamed to
`@xmldom/xmldom`; migrate to it (^0.8.13) to clear the advisories.

Changes:
- js/dav/lib/parser.js: require('@xmldom/xmldom') instead of 'xmldom'.
  The DOMParser().parseFromString(str, 'text/xml') API is unchanged.
- js/dav/package.json: swap the dependency.
- js/dav/lib/debug.js: export via module.exports so the mixed ESM/CJS
  sources bundle cleanly under a modern bundler (the original
  browserify 11 / babel 5 toolchain no longer installs). No behaviour
  change — debug(topic)(message) is preserved.
- js/dav/dav.js: regenerated browser bundle. Rebuilt with esbuild;
  the exported `dav` API surface is byte-verified identical to the
  previous bundle (36 exports, version 1.8.0) and the parser round-trips
  a CalDAV/CardDAV multistatus document.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Signed-off-by: Thomas Müller <[email protected]>
@DeepDiver1975
DeepDiver1975 requested a review from a team as a code owner July 6, 2026 21:22
@phil-davis
phil-davis merged commit 0d133ae into master Jul 6, 2026
10 checks passed
@phil-davis
phil-davis deleted the fix/xmldom-security-migration branch July 6, 2026 21:54
oc-tmueller added a commit that referenced this pull request Sep 22, 2026
The Contacts app loaded but showed no address books and no contacts on
ownCloud 11. Every call into the vendored dav library's request templates
threw "template.propfind is not a function", eight times per page load.

js/dav/lib/template/index.js was CommonJS re-exporting six modules that
are each ESM with a single `export default`:

    exports.propfind = require('./propfind');

Under the original babel 5 pipeline a lone default export was collapsed
onto module.exports, so that yielded the function. esbuild - which built
the bundle currently committed - follows the spec instead: require() of
an ESM module yields the namespace object. So template.propfind became
{ default: fn } and every template.X(...) call site in lib/request.js
threw. All six templates were affected: propfind, addressBookQuery,
calendarQuery, syncCollection, mkcol and proppatch, which between them
cover listing, searching, sync, creating an address book and renaming
one - effectively the whole app.

The barrel now re-exports the default bindings explicitly, which is
correct under any bundler and does not depend on babel 5's semantics.

Also make js/dav/dav.js reproducible, because it was not. Rebuilding it
needed three things the repository did not contain:

- shims/xmlhttprequest.js, a one-line browser shim for the node-only
  xmlhttprequest package. The committed bundle embeds it from
  ../../../shims/xmlhttprequest.js - a path outside the repository.
- a locked dependency tree. Runtime dependencies are compiled into the
  bundle, so the ^0.8.13 range on @xmldom/xmldom silently made the
  artifact float; `url` additionally has to stay at 0.11.0, since 0.11.1+
  swap querystring for qs and pull in ~45 further modules. Direct
  versions are now exact and package-lock.json is committed, un-ignored
  by name in .gitignore.
- the esbuild invocation itself, which was recorded nowhere. 0d133ae
  (#775) switched bundlers but left the Makefile describing the babel 5 +
  browserify pipeline it had replaced, which is how the bundle came to
  drift from its sources undetected.

The Makefile's dav.js target now runs esbuild, `npm ci` builds from the
lockfile, and two consecutive runs produce a byte-identical bundle. Its
dav.min.js target also worked only by accident before: uglify-js 2.x has
an ES5-only parser and cannot read esbuild output at all, so `make` in
js/dav failed on its default goal. It now minifies with esbuild, and
dav.js - the only artifact this repository consumes - is the default
goal.

Rebuilding moves the bundled @xmldom/xmldom from 0.8.13 to 0.8.15, which
accounts for most of the diff in dav.js; it is called out in the
changelog.

Verified against owncloud/server:11.0.0 with the app installed: before,
the address book list is empty and the console carries eight "not a
function" exceptions; after, the address book and its contacts render,
the contact detail form is populated from the vCard, the Rename / Link /
Download / Delete / Import controls appear, and the console is clean.
Confirmed the same esbuild recipe against the unfixed source still
reproduces the fault, so the repair is the source change and not the
rebuild.

Signed-off-by: Thomas Müller <[email protected]>
oc-tmueller added a commit that referenced this pull request Sep 22, 2026
…794)

* fix: restore the contact list by fixing dav template module interop

The Contacts app loaded but showed no address books and no contacts on
ownCloud 11. Every call into the vendored dav library's request templates
threw "template.propfind is not a function", eight times per page load.

js/dav/lib/template/index.js was CommonJS re-exporting six modules that
are each ESM with a single `export default`:

    exports.propfind = require('./propfind');

Under the original babel 5 pipeline a lone default export was collapsed
onto module.exports, so that yielded the function. esbuild - which built
the bundle currently committed - follows the spec instead: require() of
an ESM module yields the namespace object. So template.propfind became
{ default: fn } and every template.X(...) call site in lib/request.js
threw. All six templates were affected: propfind, addressBookQuery,
calendarQuery, syncCollection, mkcol and proppatch, which between them
cover listing, searching, sync, creating an address book and renaming
one - effectively the whole app.

The barrel now re-exports the default bindings explicitly, which is
correct under any bundler and does not depend on babel 5's semantics.

Also make js/dav/dav.js reproducible, because it was not. Rebuilding it
needed three things the repository did not contain:

- shims/xmlhttprequest.js, a one-line browser shim for the node-only
  xmlhttprequest package. The committed bundle embeds it from
  ../../../shims/xmlhttprequest.js - a path outside the repository.
- a locked dependency tree. Runtime dependencies are compiled into the
  bundle, so the ^0.8.13 range on @xmldom/xmldom silently made the
  artifact float; `url` additionally has to stay at 0.11.0, since 0.11.1+
  swap querystring for qs and pull in ~45 further modules. Direct
  versions are now exact and package-lock.json is committed, un-ignored
  by name in .gitignore.
- the esbuild invocation itself, which was recorded nowhere. 0d133ae
  (#775) switched bundlers but left the Makefile describing the babel 5 +
  browserify pipeline it had replaced, which is how the bundle came to
  drift from its sources undetected.

The Makefile's dav.js target now runs esbuild, `npm ci` builds from the
lockfile, and two consecutive runs produce a byte-identical bundle. Its
dav.min.js target also worked only by accident before: uglify-js 2.x has
an ES5-only parser and cannot read esbuild output at all, so `make` in
js/dav failed on its default goal. It now minifies with esbuild, and
dav.js - the only artifact this repository consumes - is the default
goal.

Rebuilding moves the bundled @xmldom/xmldom from 0.8.13 to 0.8.15, which
accounts for most of the diff in dav.js; it is called out in the
changelog.

Verified against owncloud/server:11.0.0 with the app installed: before,
the address book list is empty and the console carries eight "not a
function" exceptions; after, the address book and its contacts render,
the contact detail form is populated from the vCard, the Rename / Link /
Download / Delete / Import controls appear, and the console is clean.
Confirmed the same esbuild recipe against the unfixed source still
reproduces the fault, so the repair is the source change and not the
rebuild.

Signed-off-by: Thomas Müller <[email protected]>

* test: guard the dav bundle's request templates

js/dav/dav.js is a generated artifact that karma already loads, but
nothing asserted anything about it, so the interop break in the previous
commit passed CI green: the whole app was unusable while every test
passed.

Adds a spec that builds a propfind, addressBookQuery and syncCollection
request and checks the rendered propfind body. Verified as a real gate by
running it against the broken bundle, where four of the five cases fail
with the production error - "TypeError: template.propfind is not a
function" - and against the fixed bundle, where all pass.

Signed-off-by: Thomas Müller <[email protected]>

* fix(build): close the remaining drift holes around the dav bundle

Follow-up to the previous two commits, from reviewing them.

- .github/workflows/main.yml: a `dav bundle` job rebuilds js/dav/dav.js
  and fails if it differs from the committed bundle. The previous commits
  supply a correct Makefile and a lockfile but no gate, so an edit under
  js/dav/lib with no rebuild would ship a stale bundle exactly as before.
  Since the build is byte-reproducible from the lockfile, comparing
  against the worktree is reliable. Two details matter: the bundle is
  deleted before the rebuild, so the job cannot pass by having `make`
  decide nothing was out of date - which is what would happen the moment
  node_modules gets cached - and the comparison uses
  `git status --porcelain`, since `git diff` reports neither untracked
  nor deleted paths and so would call a PR that dropped dav.js from the
  index "in sync". Verified all three ways: green in sync, red on an
  edited template, red on a bundle removed from the index.

- js/dav/Makefile: `npm ci` instead of `npm install`, with
  package-lock.json as a prerequisite. Without it, bumping a dependency
  in the lockfile alone left make thinking dav.js was up to date and the
  superseded dependency stayed compiled in. `clean` no longer deletes
  dav.js, which is tracked - it used to remove the bundle the app loads
  and leave the worktree broken. The minify target uses --sourcemap
  rather than --sourcemap=external: the latter omits the
  sourceMappingURL comment, which would orphan the map where the uglify
  invocation it replaces emitted the link.

- js/dav/package.json: drop browserify. Nothing has referenced it since
  the bundler switch, and it was the largest contributor to the
  lockfile - removing it takes the lock from 236K to 181K and drops a
  duplicate punycode. babel stays: test/mocha.opts still uses
  babel/register.

- js/dav/package-lock.json: regenerated clean. The first version carried
  an extraneous punycode 1.4.1 that `npm install` would delete, so the
  committed lockfile was not the tree npm considered canonical and a
  build dirtied the worktree. `npm install` is now idempotent against it.

- js/dav/.gitignore: ignore dav.min.js.map, the map's new name.

- js/tests/dav_bundle.js: cover the other three templates - mkcol and
  proppatch, which back creating and renaming an address book, and
  calendarQuery. All six now fail against the broken bundle and pass
  against the fixed one.

The only change to dav.js is two module-path comments: with the
extraneous entry gone, url's punycode 1.3.2 hoists to the top level
instead of staying nested. The bundled version is unchanged.

Note that `dav bundle` is not yet in the contacts-status-checks ruleset,
so it reports but cannot block a merge until owncloud/admin adds it.

Signed-off-by: Thomas Müller <[email protected]>

---------

Signed-off-by: Thomas Müller <[email protected]>
Co-authored-by: Thomas Müller <[email protected]>
oc-tmueller added a commit that referenced this pull request Sep 22, 2026
Cuts 1.6.0, the first release since 1.5.5 (2018-12-11).

- CHANGELOG.md: [Unreleased] closed out as [1.6.0], link refs updated
- sonar-project.properties: sonar.projectVersion 1.0 -> 1.6.0
- package.json: version 1.5.4 -> 1.6.0, two releases behind

appinfo/info.xml needs no change - it already declares 1.6.0, bumped in
5c9b81e along with the min-version/max-version 11 dependency and the
PHP 8.3 requirement, but never tagged. The release workflow added by
#793 enforces that the tag matches <version>.

Dropping ownCloud 10 and PHP < 8.3 gets its own Removed section rather
than a bullet in the middle of Changed: it is the one fact in this
changelog that can leave an administrator with a disabled app after an
upgrade, so it should not be easy to skim past. For the same reason #775
is under Security rather than Fixed - it replaces a bundled XML parser
carrying unpatched advisories, and reads as a rename otherwise.

The #794 entry says explicitly that the regression it fixes never
reached a release. 1.5.5 predates #775 by eight years, so without that
note an administrator reading these release notes would conclude their
current install has a broken contact list and treat 1.6.0 as urgent.

The dependency line names the development toolchain explicitly: every
package.json change since 1.5.5 was a devDependency. The one bundled
runtime library that does move is @xmldom/xmldom, via #794, and that is
called out on its own line.

Signed-off-by: Thomas Müller <[email protected]>
oc-tmueller added a commit that referenced this pull request Sep 23, 2026
Cuts 1.6.0, the first release since 1.5.5 (2018-12-11).

- CHANGELOG.md: [Unreleased] closed out as [1.6.0], link refs updated
- sonar-project.properties: sonar.projectVersion 1.0 -> 1.6.0
- package.json: version 1.5.4 -> 1.6.0, two releases behind

appinfo/info.xml needs no change - it already declares 1.6.0, bumped in
5c9b81e along with the min-version/max-version 11 dependency and the
PHP 8.3 requirement, but never tagged. The release workflow added by
#793 enforces that the tag matches <version>.

Dropping ownCloud 10 and PHP < 8.3 gets its own Removed section rather
than a bullet in the middle of Changed: it is the one fact in this
changelog that can leave an administrator with a disabled app after an
upgrade, so it should not be easy to skim past. For the same reason #775
is under Security rather than Fixed - it replaces a bundled XML parser
carrying unpatched advisories, and reads as a rename otherwise.

The #794 entry says explicitly that the regression it fixes never
reached a release. 1.5.5 predates #775 by eight years, so without that
note an administrator reading these release notes would conclude their
current install has a broken contact list and treat 1.6.0 as urgent.

The dependency line names the development toolchain explicitly: every
package.json change since 1.5.5 was a devDependency. The one bundled
runtime library that does move is @xmldom/xmldom, via #794, and that is
called out on its own line.

Signed-off-by: Thomas Müller <[email protected]>
Co-authored-by: Thomas Müller <[email protected]>
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