Commit Graph
138 Commits
Author SHA1 Message Date
Lauri Ojansivu 582a22c291 Fix GitHub code scanning code-quality findings.
Real faults: a card's original-position description formatted a promise
because it did not await the history; the attachment swipe distances and
two drag-scroll locals were undeclared globals; a file that cannot be read
during a GridFS upload left the upload open; api.py called exit() instead of
sys.exit(); a rules test redefined a property and a security-log test kept
an unreachable branch. Also 31 missing semicolons, unused imports in the
card details, exporters and attachment API, unused Python imports, and
comments on empty except clauses. The list-sync scanner test cut its source
at the last Meteor.startup, which the new index startup of #6855 had moved.

Thanks to GitHub CodeQL and xet7 !
2026-11-02 14:15:02 +02:00
Lauri Ojansivu 0afb1336db SVG is uploaded and shown as an image: an attachment, a cover, a board background, an avatar.
Since JVN#74210258 (stored XSS) an SVG upload was refused and any stored
SVG was served as a download, so an SVG could not be a card's picture.
Every uploaded SVG is already sanitized on the server before it is
stored - no script, event handler, javascript: URI, foreignObject or
DOCTYPE/ENTITY XML loop (models/lib/sanitizeUploadedFile.js) - so the
refusal goes, for attachments and avatars.

Serving it inline is made safe in one place, server/lib/svgResponse.js,
used by every route that sends file bytes (universalFileServer.js for
attachments, avatars and legacy files, avatarServer.js,
legacyAttachments.js and httpStream.js): the WHOLE file is sanitized
again before it is sent, whatever is stored, and sent as image/svg+xml
under a Content-Security-Policy with default-src 'none' and sandbox, no
script, X-Frame-Options DENY and nosniff, so even opened directly as a
page it runs nothing. A download is sanitized too; a range request gets
the whole file; an SVG over 8 MB stays a sandboxed download. A file whose
active markup is removed on the way out is logged to Admin Panel /
Problems like the stream sanitizer's, and one removed at upload trips
the existing sanitize.dangerous-content canary.

tests/svgServing.test.cjs runs the real sanitizer on a crafted SVG
(script, onload, javascript:, DOCTYPE/ENTITY, foreignObject/iframe) and
checks the body and headers, the download, the oversized case, and that
no file-serving route in server/routes or httpStream.js sends bytes
without the SVG path, and that nothing else sends image/svg+xml;
tests/playwright/specs/svg-attachment.e2e.js uploads one, checks what is
served, that it shows in the card without running anything, and makes
it the cover and the board background.

Thanks to xet7 !
2026-10-25 06:32:25 +02:00
Lauri Ojansivu 31e569a18e Single-file WeKan for every platform with a Node.js bundle.
One executable per platform: that platform's published bundle repackaged
as a Node.js single executable application whose ZIP Node 26.11 mounts as
a virtual file system (useVfs + vfsArchive). Only FerretDB is copied out,
once and verified, to wekan-files/bin; native addons load from the VFS.

Everything WeKan writes is in wekan-files beside the executable, which
WRITABLE_PATH points at: attachments, avatars, db, bin, backup, logs,
versions. WeKan now treats a WRITABLE_PATH named wekan-files as the files
root (models/lib/filesRoot.js, shared by every place that derived it).

Started in a terminal it shows a menu: start, stop, status, version info
as Admin Panel / Version shows it, update to the newest release or change
to any other (checksum verified, backed up first, the old executable
kept), backup to wekan-files/backup/YYYY-MM-DD_HH-MM-SS, run at boot
(systemd, launchd, Task Scheduler, cron, Termux:Boot), log, settings.
Every entry is also a command. start runs the start-wekan.sh loop:
recovery, requested restore, FerretDB, recovery page, WeKan, restart.

Meteor's main.js chdir()s into the bundle, which a VFS cannot be, so the
server role keeps a virtual working directory. Node 26.11.1 breaks
fs.writev/readv while any VFS is mounted; they are rebuilt on fs.write
and fs.read.

single-file.yml builds every target in releases/single-file/targets.json
from its verified bundle (Macs on a Mac, to re-sign), starts it where a
runner exists with browser tests on amd64, and attaches what started.
Release All and Release All Missing call it.

Thanks to xet7 !
2026-10-13 21:08:09 +03:00
Lauri Ojansivu 4caa929cfe Fix CodeQL alerts 562, 563 and 564, and the same shapes elsewhere.
Alert 564 (regex injection): releases/platform-native-packages.mjs compiled
its command-line platform and arch into a RegExp. The canvas package names
are now compared as strings. The upload naming of attachments and avatars,
the attachment rename popup and tools/mirror-menu.mjs built a RegExp from a
file extension or a name the same way; they use literal suffix and prefix
checks now. tests/noUnescapedDynamicRegExp.test.cjs parses every source file
and fails on a RegExp built from a value that is not escaped, unless the
site is listed with the reason its values are constants.

Alert 563 (incomplete escaping): name.replace('/', '%2F') replaced only the
first slash. registryPackagePath() replaces every one and refuses anything
that is not an npm package name. Seven tests escaped a regex the same
first-only way; 'g++'.replace('+', '\\+') let "- g+" pass a guard. They use
the complete escapeRegExp, and tests/noIncompleteRegExpEscaping.test.cjs
fails on any string-pattern replace that performs an escape.

Alert 562 (ReDoS): the CasaOS reverse-domain id pattern in
tests/platformTemplates.test.cjs let '.' be matched by both groups, so
'0.0.0...!' backtracked exponentially. Each separator now belongs to one
group, and the test runs CodeQL's attack string against it.

Thanks to GitHub CodeQL and xet7 !
2026-10-12 02:18:33 +03:00
Lauri Ojansivu 06b8ea5750 Close the UploadPathBleed avatar sibling: an avatar's client-supplied file id cannot traverse paths.
The on-disk name of an upload starts with its file id, which the client sends
in opts.meta.fileId. Attachments validated it (UploadPathBleed); avatars - the
same Meteor-Files pipeline - used it verbatim, so an avatar upload with a
fileId like ../../x wrote outside the avatar store, and Avatars.onBeforeUpload
did not require a signed-in user. Both collections now share one rule
(models/lib/uploadFileId.js): an id that does not look like WeKan's own is
replaced with a fresh one and the attempt recorded; avatars need a signed-in
uploader. The negative test fails on any namingFunction in the tree without
the rule.

Thanks to xet7 !
2026-10-02 11:05:04 +03:00
Lauri Ojansivu 77c3957e5c Fix CacheBleed: serve attachments and avatars as private, revalidated responses.
GHSA-w3qg-pf27-g68r: attachments were answered with
Cache-Control: public, max-age=31536000 and no Vary after the board access
check, so a shared cache (CDN, caching proxy) could store a member's copy and
serve it to anyone without credentials for a year, also after the member was
removed from the board. The same header was in setFileHeaders, both ?download=1
branches, both avatar routes, and Meteor-Files' own /cdn/storage route sent its
default public, s-maxage one-year header.

Every file response, its 304 and the thumbnail now send
Cache-Control: private, no-cache and Vary: Cookie, Authorization, X-Auth-Token
through models/lib/fileCacheHeaders.js, for public boards too, because a board
made private later would leave a public copy behind. Both FilesCollections pass
the same cacheControl. The ETag keeps revalidation a bodiless 304.

tests/fileCacheHeaders.test.cjs drives the policy against the shared-cache rules
the report used, checks each route, and fails on any public Cache-Control, a
FilesCollection left on the Meteor-Files default, or an ETag-sending file without
the policy, anywhere in the tree. The thumbnail Playwright spec checks the
headers on every route. Nothing is refused, so there is no Problems key.

Thanks to alham-rizvi and xet7 !
2026-10-02 08:42:18 +03:00
Lauri Ojansivu e6a894f5fc Give the 4 Attachments/Avatars advisories their own Hall of Fame names.
The upload path-traversal guard was logging under the pre-existing
PathBleed key (a different, already-published advisory,
GHSA-4mxf-m8pq-xc9p about avatar versions.path and board export) - it
now has its own UploadPathBleed key, so the two incidents are not
conflated on the public Hall of Fame page or in Admin Panel / Problems.
The two High advisories (missing Avatars.protected, unauthenticated
serveLegacyAvatar) now also log a blocked attempt, under new
authz.avatar-protected/PortraitBleed and
authz.legacy-avatar/RelicAvatarBleed keys, matching the site entries
added at .tools/wekan.fi.

tests/securityRegressionCoverage.test.cjs's inventory and
tests/attachmentAvatarSecurityAdvisories.test.cjs are updated so all four
names (WipeBleed, UploadPathBleed, PortraitBleed, RelicAvatarBleed) are
recognized as GUARDED, matching the published Hall of Fame count.
2026-09-09 18:15:10 +03:00
Lauri Ojansivu 9947e0138a Fix 4 security advisories in Attachments/Avatars (ostrio:files 3.0.1).
CRITICAL - Unauthenticated Arbitrary File Write via Path Traversal in
Attachment Upload namingFunction: Attachments overrode ostrio:files'
sanitize() to an identity function and used the client-supplied fileId
verbatim as the on-disk file name, so an anonymous upload with
fileId: "../../../../tmp/pwn" could write attacker-controlled content
anywhere the WeKan process can write. sanitize() is restored to the same
whitelist models/avatars.js already used for the same tokens, and
namingFunction now validates the (sanitized) fileId against the ObjectId
shape WeKan itself generates, regenerating a fresh one otherwise.

CRITICAL - Unauthenticated DDP Methods _FilesCollectionRemove_attachments/
_FilesCollectionRemove_avatars Allow Instance-Wide Deletion: ostrio:files
registers its own remove method, gated only by allowClientCode and never
routed through Attachments.allow/Avatars.allow (those only gate the
ordinary Mongo .remove() call). Attachments had no onBeforeRemove at all
and Avatars' unconditionally returned true, so any anonymous DDP caller
could pass selector {} and wipe every attachment or avatar on the
instance. Both now require this.userId and check every matched file:
attachments need the caller's board-write access, avatars need ownership
or site-admin status.

High - Avatars Collection Lacks `protected` Callback: unlike Attachments,
Avatars never set `protected`, so ostrio:files' own library-native
download route (its _checkAccess defaults to allowing everything when
`protected` is unset) served any avatar to anyone, bypassing
isAuthorizedForAvatar entirely. Avatars.protected now mirrors
Attachments.protected: any authenticated caller, or an anonymous one only
when the avatar's owner is on a public board.

High - serveLegacyAvatar Serves Legacy CollectionFS Avatars Without Any
Authentication: both call sites in server/routes/avatarServer.js streamed
a legacy avatar to any caller who knew its old filerecord id, one of them
(/cfs/files/avatars) with no check at all. Both now require an
authenticated caller (isLegacyAvatarAuthorized) - legacy records carry no
owner/board link that can be safely checked for the public-board
exemption current avatars get, so this is deliberately narrower rather
than reusing that exemption on an unverifiable claim.

Both CRITICAL fixes log a blocked attempt through the shared security log
(new authz.file-remove/WipeBleed catalog key, and the existing
authz.file-path/PathBleed key), so Admin Panel / Problems shows an
attempt was made. tests/attachmentAvatarSecurityAdvisories.test.cjs pins
all four fixes and the negative cases (no dangling anonymous bypass, no
regression to the legitimate admin avatar-delete and public-board
redirect flows).
2026-09-09 18:15:10 +03:00
Lauri Ojansivu 829d2a6c74 Enforce Amiga-safe filenames on every read 2026-09-06 02:28:46 +03:00
Lauri Ojansivu 5d44e0b98b Sandstorm: remove the temporary MongoDB-3->FerretDB debugging diagnostics
Now that the grain boots, logs in, lists/opens boards, uploads/downloads attachments,
and migrates an old MongoDB 3 grain end to end, drop the two temporary diagnostics:

- models/attachments.js: revert the Meteor-Files debug flag to false (it was enabled on
  Sandstorm to trace the upload 'session expired [408]' issue and was spamming the grain
  log with the full FilesCollection dump and every find()).
- server/ferretdbQueryDebug.js: remove the mongodb Collection.find wrapper that logged
  FerretDB-rejected selectors (used to find the $elemMatch 'unknown operator: userId'
  issue, since fixed in wekan/FerretDB).

Thanks to xet7.
2026-07-13 04:11:22 +03:00
Lauri Ojansivu c671a7fc8c Sandstorm .spk: temporarily enable Meteor-Files debug logging on Sandstorm
Attachment uploads in the grain fail with HTTP 400 "Can't continue upload, session
expired [408]": the upload start succeeds but the per-fileId session is gone by the
time a chunk arrives (both the in-memory _currentUploads entry and the
__pre_attachments pre-collection doc are missing), which points at the polling
observe (FerretDB has no oplog) firing a spurious removed event and aborting the
upload. The Attachments FilesCollection had debug: false, so nothing about the
upload path is logged. Enable Meteor-Files debug on Sandstorm only (gated on
Meteor.settings.public.sandstorm) so the grain debug log shows the start /
createStream / observer / continueUpload steps and pinpoints where the session is
lost. TEMPORARY: revert to debug: false once the upload is fixed.
2026-07-12 22:09:57 +03:00
Lauri OjansivuandClaude Opus 4.8 f592735080 Fix #5905: notify card members and record history when an attachment is added
Uploading an attachment now creates an addAttachment activity, so card members
and subscribers are notified (consistent with attachment removal) and it appears
in card history. Previously the activity was never created because the store
strategy upload hook was dead code. buildAttachmentAddedActivity unit tested.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-20 14:40:13 +03:00
Lauri OjansivuandCopilot Autofix powered by AI 36274f35f4 Potential fix for code scanning alert no. 57: Incomplete multi-character sanitization
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2026-05-30 22:51:07 +03:00
Lauri Ojansivu 8b6c459453 Revert not working PR 6337 Fix attachments API 500 error and upload crash.
Thanks to xet7 !
2026-05-13 18:14:42 +03:00
KhaoulaMaleh ac2bacf42c attachement fix 2026-05-10 01:41:03 -11:00
Lauri Ojansivu 03e0cfdc15 Try to fix Docker and Snap.
Thanks to xet7 !
2026-04-03 20:35:54 +03:00
Lauri Ojansivu edc6b18b5f Fix Bug: WeKan v8.50 WRITABLE_PATH.
Thanks to snowsky and xet7 !

Fixes #6242
2026-04-03 20:16:32 +03:00
Harry Adel 63ce45c538 Split shared models from Meteor 3 server runtime 2026-03-24 01:50:39 +02:00
Harry Adel 620e5ce9dc Meteor 3.4 migration: Convert remaining sync methods to async
Convert all remaining Meteor.methods with sync collection calls:
- users.js: deleteWorkspace → async with findOneAsync/updateAsync
- userPositionHistory.js: 3 methods → async with insertAsync/fetchAsync
- attachmentStorageSettings.js: 4 methods → findOneAsync/insertAsync/upsertAsync
- org.js, team.js, translation.js: insert → insertAsync
- boards.js: acceptInvite + collection hooks → updateAsync
- settings.js: sendInvitation → updateAsync/insertAsync
- import.js: importBoard/cloneBoard → async with await creator.create()
- attachments.js: onAfterUpload → async with findOneAsync/updateAsync
2026-03-22 17:50:31 +02:00
Harry Adel 2e3fbf25db Meteor 3.4 migration: Convert allow/deny callbacks to async
Meteor 3.x supports async allow/deny callbacks. Convert all 25 sync
allow/deny callbacks across 23 model files to use async/await with
findOneAsync/fetchAsync instead of sync findOne/find().fetch().

Also converts helper functions in server/lib/utils.js:
- allowIsBoardMemberWithWriteAccessByCard -> async
- allowIsBoardMemberByCard -> async
- canUpdateCard (cards.js) -> async
- permissionHelper.allow (integrations.js) -> async
2026-03-22 17:44:29 +02:00
Lauri Ojansivu be5bdbe314 Export Card to Excel and related fixes. Part 1.
Thanks to xet7 !

Fixes #5324
2026-03-21 20:57:07 +02:00
Lauri Ojansivu 274f1309c3 Fixed unable to delete Avatar, with Meteor 3 compatible avatar and attachments fixes.
Thanks to inDane and xet7 !

Fixes #6160
2026-03-05 17:27:33 +02:00
Harry Adel e77be37450 Use sync code in allow/deny for 2.x 2026-02-19 00:26:47 +02:00
Harry Adel 71eb01e233 Update ReactiveCache call sites to use async/await for Meteor 3.0
Part 3 of ReactiveCache async migration:
- Add await before all ReactiveCache.getX() calls
- Make functions containing ReactiveCache calls async
- Convert forEach/map/filter loops with async callbacks to for...of
- Update model helpers, Meteor methods, JsonRoutes handlers
- Update collection hooks (.before/.after insert/update/remove)
- Update .allow() callbacks to async

Files updated across models/ and server/ directories:
- Model files: cards, boards, lists, swimlanes, activities, users,
  checklists, checklistItems, customFields, attachments, integrations,
  cardComments, settings files, creators, exporters, and more
- Server files: publications, methods, notifications, routes, migrations
2026-02-01 00:54:38 +02:00
Lauri Ojansivu a419d831a4 Fix Filebleed of Floppybleed.
Thanks to Luke Hebenstreit Twitter lheben_ and xet7 !
2026-01-28 13:20:28 +02:00
Harry Adel ca2083c858 Migrate createIndex to createIndexAsync 2026-01-24 01:55:29 +02:00
Lauri Ojansivu c413a7e860 Security Fix 8: MoveStorageBleed.
Thanks to [Joshua Rogers](https://joshua.hu) of [Aisle Research](https://aisle.com) and xet7.
2026-01-18 19:45:44 +02:00
Lauri Ojansivu eabb6a239d Fix New Board Permissions: NormalAssignedOnly, CommentAssignedOnly, ReadOnly, ReadAssignedOnly. Part 1.
Thanks to nazim-oss and xet7 !

Related #6060
2026-01-14 23:43:11 +02:00
Lauri Ojansivu e9a727301d Fix SECURITY ISSUE 1: File Attachments enables stored XSS (High).
Thanks to Siam Thanat Hack (STH) !
2025-11-02 08:36:29 +02:00
Lauri Ojansivu 30620d0ca4 Some migrations and mobile fixes.
Thanks to xet7 !
2025-10-25 21:09:07 +03:00
Lauri Ojansivu 4283b5b0e3 Disable not working minio and s3 support temporarily.
Thanks to xet7 !
2025-10-16 17:49:39 +03:00
Lauri Ojansivu cc99da5357 Fixed Error in migrate-lists-to-per-swimlane migration.
Thanks to xet7 !

Fixes #5918
2025-10-13 20:34:23 +03:00
Lauri Ojansivu bd8c565415 Fixes to make board showing correctly.
Thanks to xet7 !
2025-10-12 03:48:21 +03:00
Lauri Ojansivu ae1f80a52c Added attachments API and admin panel attachment management for file storage backends settings. Fixed drag drop upload attachments from file manager to minicard or opened card.
Thanks to xet7 !
2025-10-11 11:05:46 +03:00
Lauri Ojansivu e1fa607f87 Security Fix JVN#74210258: Stored XSS.
Thanks to Ryoya Koyama of Mitsui Bussan Secure Directions, Inc and xet7 !
2025-10-10 23:06:06 +03:00
Lauri Ojansivu 9720e703fd Security Fix JVN#14269684: Broken access control.
Thanks to Ryoya Koyama of Mitsui Bussan Secure Directions, Inc and xet7 !
2025-10-10 22:59:20 +03:00
Lauri Ojansivu 30c1597b65 Security Fix FG-VD-22-078: Prevent SVG Billion Laughs Attack.
Thanks to Nguyen Thanh Nguyen of Fortinet's FortiGuard Labs and xet7 !
2025-10-10 22:16:47 +03:00
Lauri Ojansivu a8de2f224f Use attachments from old CollectionFS database structure, when not yet migrated to Meteor-Files/ostrio-files, without needing to migrate database structure.
Thanks to xet7 !
2025-10-10 19:07:04 +03:00
Martin Filser 3fc9c6efe7 Move every Attachments.findOne() to the ReactiveCache 2023-07-18 21:25:28 +02:00
Martin Filser a182482cfb Move every Boards.findOne(boardId) to the ReactiveCache (Part 2) 2023-07-18 21:25:28 +02:00
Lauri Ojansivu aef6967d4c Fix Exception in callback of async function: TypeError: this._now is not a function. Part 2.
Thanks to xet7 !
2023-04-21 22:03:47 +03:00
Lauri Ojansivu aeb0f1e6d8 Fix Exception in callback of async function: TypeError: this._now is not a function.
Thanks to xet7 !
2023-04-21 21:15:00 +03:00
Lauri Ojansivu 76ac070f9b Save files serverside with filename ObjectID, without filename.
Thanks to g-roliveira, iamabrantes, Floaz, koelle25, scott-dunt, mfilser and xet7 !

Fixes #4416
2023-04-17 23:42:56 +03:00
Lauri Ojansivu f11650ece1 Added more descriptive times of attachment migrations and uploads.
Thanks to xet7 !

Related https://github.com/wekan/wekan/issues/4891
2023-04-14 15:16:50 +03:00
Lauri Ojansivu fd9478dc57 Try to fix build errors on some platforms.
Thanks to xet7 !

Related #4842
2023-02-21 21:27:34 +02:00
Lauri Ojansivu 382168a5b4 Try to fix some security issues. Part 2.
Thanks to responsible security disclosure contributors and xet7 !
2023-02-20 16:48:02 -05:00
Lauri Ojansivu ff993e7c91 Try to fix some security issues.
Thanks to responsible security disclosure contributors and xet7 !
2023-02-20 01:21:33 +02:00
Lauri Ojansivu cd1750f368 Forked minio npm package to @wekanteam/minio to update package dependencies. S3/MinIO support In Progress.
Thanks to xet7 !

Related #142
2023-01-16 15:11:31 +02:00
Martin Filser f6fbd0a5c2 Attachment, rename not needed anymore since Meteor-Files 2.3.0
Thanks to @dr-dimitru
https://github.com/wekan/wekan/pull/4638#issuecomment-1217883870

https://github.com/veliovgroup/Meteor-Files/commit/00ab6f723b84eb596b366c5d26e6981a00377809
2022-08-21 11:10:27 +02:00
Martin Filser 25443926d3 Attachment, path was wrong if the file hasn't a extension 2022-08-21 11:10:27 +02:00