mirror of
https://github.com/wekan/wekan.git
synced 2026-11-25 04:49:41 -05:00
v11.36
5
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
d8d1863dba |
Login offices: who logs in from where, and users shown as initials or avatar.
WHAT WAS ALREADY THERE, checked first: server/lib/loginAttemptThrottle.js resolves a client address for the REST throttle, the lockout resolves one for DDP, models/users.js has getInitials() and profile.avatarUrl, the board sidebar and cards show members through +userAvatar / +userAvatarInitials, cardDetails.js builds "open in map" links for a dozen providers, and Admin Panel tables already had a js-table-page-edit-user handler and a `userId` column option. All of it is reused rather than rewritten; only geolocation from CDN headers is new. THE TALLY, both directions from one successful login. On the user: which addresses this account uses - `100.100.100.100 25, 122.122.122.122 50`. On a new loginAddresses collection: which accounts use each address. Capped both ways with an overflow count, as the Problems summaries are. WHY THE SECOND DIRECTION EXISTS: an address several accounts log in from is an office, a VPN, a university, a carrier's NAT. Blocking it takes everyone behind it off WeKan at once - including the reverse proxy itself if HTTP_FORWARDED_COUNT is wrong, which is every user there is. So WeKan blocks the ACCOUNT that attempted the vulnerability and never the address, and this record is what lets an admin see that shape before drawing any conclusion from an address. Blocking uses loginDisabled, the field Admin Panel / People already toggles, so an admin unblocks from the table they know and no second notion of "blocked" appears beside the one that exists. `services.securityBlock` records why, from what and when. Only a 'blocked' action at high or critical severity, and only with a userId: an unauthenticated attempt has nobody to block, and guessing from the address is the mistake above. LOCATION, when something in front of WeKan already knows it: Cloudflare, Fastly, CloudFront, Vercel, Google Cloud or a hand-configured proxy. WeKan does no geolocation of its own - no database to ship, no third-party lookup of a user's address. An office in London is labelled London. DISPLAY ONLY, and the file says so twice: anything a client can send it can forge, and X-Forwarded-For at least has HTTP_FORWARDED_COUNT to say how much to believe, where a city name has nothing. USERS AS INITIALS OR AVATAR, in every Admin Panel / Problems table at once - it is one line of the shared table page, so Security, Speed, Tests, CPU, Database, Integrity and Impersonation all change together. The name is the title, so hovering still says who it is, and clicking opens the existing "Edit user" popup. Not +userAvatar: it renders its own anchor for the board's member popup, and an anchor inside the cell's anchor is invalid and would swallow the click. mapLinkFor and its Chinese datum conversions move to models/lib/mapLink.js so the card and the Admin Panel build map links the same way, with the user's own profile.mapProvider choice applying in both. Thanks to xet7 ! |
||
|
|
3d08c65bb2 |
Admin Panel Problems: one summary row per problem, with who tried and how often.
A guard on a path an attacker controls fires as fast as they can send. One
document per event meant the database grew with the attack, the Problems page
became a scroll of near-identical lines, and the one event that mattered was
buried under ten thousand that did not. The admin's question is never "list
every attempt" - it is what is happening, how much, since when, and who.
So each problem is ONE row that accumulates:
count how many times this problem has happened
firstAt … at the window it happened in
actors who, each with their own count:
username1 25, 100.100.100.100 30
username/ip the most recent occurrence
WHAT MAKES TWO EVENTS THE SAME PROBLEM is the whole design. Identity is the KIND
of thing that happened - stream, bleed, category, action, source, severity, CWE,
and the database stream's own type/db/kind. The actor is NOT part of it: a
username or an address in the key gives a row per attacker per attempt, which is
the cost being removed.
A USERNAME AND AN ADDRESS ARE TALLIED SEPARATELY, not as a pair. They answer
different questions - which account, and where from - and an unauthenticated
attempt has an address and no name. Pairing them would split one attacker across
a line per address and answer neither.
THE TALLY IS CAPPED at 50 actors, with the rest counted in actorsOverflow.
Otherwise an attacker rotating addresses grows the row with the attack and
reintroduces the same bug one level down - and "and 9,412 others" is itself the
signal that the source is spread rather than single. The cap needs to know
whether an actor is new to the row, so the row's actor keys are cached per
process: reading it on every attempt would double the database work of the thing
being made cheap, and under attack the same few actors repeat.
All three loggers share the fold (server/lib/eventLogFold.js) - a slow query in
a loop and a test failing on every run repeat just as a guard under attack does.
Still fire-and-forget and still unable to throw into the caller.
EXISTING PER-EVENT ROWS ARE FOLDED IN PLACE at startup, in batches, in JS so it
behaves the same on FerretDB as on MongoDB, and idempotently - a row with firstAt
is already a summary. Nothing is lost that the summary does not carry: counts are
summed, the earliest becomes firstAt, the latest becomes at, and the latest
occurrence's actor and detail are what the row keeps.
AND A COVERAGE CHECK, as asked: tests/hallOfFameProblemsCoverage.test.cjs
requires every hall-of-fame vulnerability to be keyed, deliberate (with the
reason, as HashBleed is), or pending. 30 of 66 are keyed; the other 35 predate
the rule and are listed as pending rather than judged here, because deciding
whether a given fix has anything to detect means reading that fix and claiming
otherwise would be worse than the gap. The pending list may shrink and may never
grow, so a NEW vulnerability without a key fails.
It found one real fault immediately: the catalog said OidcBleed and the site says
OIDCBleed, so attempts were grouping under a name nobody could look up.
Thanks to xet7 !
|
||
|
|
d577f07700 |
Canary tokens: who tried to override permissions, and from where.
The security event log said what a guard DID - a request blocked, a filename
sanitized - which answers "is WeKan defending itself" and not the question an
admin asks next: who did that, and from where. It also could not tell a browser
that got confused from somebody working through the Hall of Fame one entry at a
time.
A CANARY is a tripwire at a point that only a permission-override attempt
reaches. Ordinary use never gets there - the code path runs when a request asks
for something the rules forbid - so a trip is not noise, and it is worth an
admin's attention with the actor attached. Design:
docs/Security/Remediation/WeKan.md §12.
Three properties, each enforced by a test:
SILENT. Tripping one changes NOTHING the caller can observe. tripCanary()
always returns false and tripCanaryDeny() always returns true, so a call site
reads as the refusal it replaces:
if (forbidden) return false; // before
if (forbidden) return tripCanary('card.vote-field', { userId });
The return value is decided before any reporting is attempted and the reporting
is wrapped, so a canary can never throw into, delay or disturb the request it
watches. The REST handler re-throws the ORIGINAL error object. This is not
politeness: a canary that announces itself is a map of which paths are watched,
and a probe would simply avoid them.
BOUNDED. A canary sits where an attacker can loop, so one row per attempt would
be a denial of service they get for free. models/lib/canaryTokens.js - pure, no
Meteor, no clock of its own - records the first trip of a (canary, actor) pair
at once, COUNTS the rest of the window, flushes one summary carrying the total
when the window closes, and stops writing after 60 summaries for a pair that
never gives up. The tracked-pair map is capped at 5000 and evicts the LEAST
RECENTLY seen, so a long-running attacker is not pushed out by a passing one and
a botnet varying its address cannot grow it. Idle pairs are swept on a timer. A
thousand attempts in a minute cost ONE row, and a suppressed trip costs one map
lookup. The username lookup is cached and capped, and neither it nor the insert
is awaited on the caller's path.
ATTRIBUTED. Every event carries userId, username, ip and count. The username is
denormalised at write time on purpose: it is what the account was CALLED when it
tried, so a rename does not rewrite history and a deletion does not erase it.
The address uses the same spoofing-safe resolver as the login throttle -
X-Forwarded-For only as far as HTTP_FORWARDED_COUNT says to trust it - or an
attacker could write a colleague's address into the security log by sending a
header. `detail` says what was attempted in the words of the feature, never the
payload.
Seventeen canaries are wired at the permission checks that refuse the attempts
behind BoardBleed, ParentBleed, ChecklistBleed, PathBleed and CommentBleed, plus
the direct vote/poker field writes and a stored path that points outside the
storage root. All server-side: no Playwright, no browser, nothing to install.
Admin Panel / Problems / Security gains Username, IP address and Attempts
columns, and both new columns are searchable - the thing an admin does with one
security event is pivot on it.
tests/canaryTokens.test.cjs (25 checks) drives the limiter through bursts, an
endless probe, eviction order and junk input; tests/canaryCoverage.test.cjs (18)
pins every canary to its call site and asserts none of them changes what the
caller gets back.
Thanks to xet7 !
|
||
|
|
1d82ef8eae |
Security/speed/tests logging: store in the existing WeKan DB (no new files).
Per correction: use only the existing WeKan database via Meteor JavaScript
queries (works on FerretDB and MongoDB); do not create files/DBs under
WRITABLE_PATH; and have FerretDB report problems to WeKan rather than writing
itself.
- models/eventLog.js: one `eventlog` collection (stream: security|speed|tests).
- server/lib/{securityLog,speedLog,testLog}.js: thin wrappers that insert one
document via EventLog.insertAsync (fire-and-forget, never throw).
- models/lib/securityLogFormat.js slimmed to just sanitizeDetail; remove the
node:sqlite event store (server/lib/eventStore.js) and all file/path/schema
helpers.
- Add a Tests stream: log anything that would fail an existing WeKan test.
- Design docs (WeKan.md, FerretDB.md) rewritten: DB-collection storage, grouped
counts for the summary, Admin Reports read the collection, and FerretDB reports
problems to WeKan which records them (no FerretDB DB/file writes).
- tests/securityLog.test.cjs updated (sanitizer + catalog + collection wiring +
no-filesystem guards); verified via Python mirror.
|
||
|
|
9f07aa4506 |
Security/speed logging: foundation loggers + first upload/avatar/SSRF wiring.
Implements the core of docs/Security/Remediation/WeKan.md: - models/lib/securityLogFormat.js: pure, unit-testable helpers (dated run-dir path, disk-space guard, one-line format, parse, per-category/Bleed/severity tally, summary render). - models/lib/securityCategories.js: general-category <-> hall-of-fame *Bleed catalog (RedirectBleed, LiveBleed, SourceBleed, MetricsBleed, InviteBleed, ...). - server/lib/securityLog.js + speedLog.js: best-effort, never-throwing writers to WRITABLE_PATH/files/security|speed/YYYY-MM/DD/HH_MM_SS/ (wekan-log.txt + wekan-summary.txt / wekan-speed-*), with a disk-space check before every write and a dropped-events counter. - Wire first remediation/rejection points to emit events: avatar-URL scheme rejection (setAvatarUrl), Trello live-import attachment SSRF block, and avatar localization SSRF block (covers the requested attachment/avatar rejection + sanitization logging). - tests/securityLog.test.cjs (unit + negative tests), wired into test:unit:node. Admin Panel Reports (Security/Speed UI), the FerretDB Go logger, and full guard coverage are the next phase (fully specified in the design docs). |