Commit Graph
4014 Commits
Author SHA1 Message Date
Jordi Mallach a863283680 feat(web): add optional Content Security Policy
AngularJS (EOL since 2022-01) and AngularJS Material no longer receive
security fixes, so any new vulnerability in them will stay unpatched.
In AngularJS, templates are code: any attacker-controlled text that
ends up in a compiled template is evaluated as an expression, and
since 1.6 there is no expression sandbox, so a single
{{constructor.constructor('...')()}} gives full script execution.
SOGo renders untrusted data (mail bodies, invitations, attachment
names, contact fields) into such templates and currently relies on
server-side filtering, like stripping "{{" and "}}", to prevent this.
Any gap in that filtering, or a bypass of $sanitize/ng-bind-html,
would mean XSS in the webmail session: reading and sending mail as
the user, and access to calendars and contacts.

A Content Security Policy adds a second layer in the browser that
doesn't depend on catching every injection. The new
SOGoContentSecurityPolicy system default ("report-only" or "enforce",
disabled when unset) sends a strict policy with the pages of the web
interface:

  script-src 'self' 'nonce-<random>'   (no 'unsafe-inline'/'unsafe-eval')
  style-src 'self' 'unsafe-inline'     (Angular Material, CKEditor 5)
  object-src 'none'; base-uri 'self'; frame-ancestors 'self'; ...

The policy is generated by sogod, since a fresh 128-bit nonce is needed
per response: it is shared by all components of the response and set
on the inline configuration scripts of the page frame and module views.
The page also gets ng-csp="no-unsafe-eval", so AngularJS evaluates
expressions with its interpreter instead of Function().

With the policy enforced, an expression injected into a compiled
template, such as {{constructor.constructor('...')()}}, can no longer
reach Function() and fails with an EvalError, and injected inline
scripts are blocked. Injected expressions are limited to calling
functions available on the scope.

Tested with Chromium in both modes on login, Mail (HTML messages,
remote content, invitations, compose), Calendar and Contacts editors,
Preferences and Administration: no violations from SOGo's own code.
With the default unset, the generated output is unchanged.

form-action is deliberately not restricted, so SAML2/CAS/OpenID
logins posting to an external IdP keep working. Scripts listed in
SOGoUIAdditionalJSFiles are served from WebServerResources and allowed,
but must not load scripts from other origins, use eval() or rely on
inline handlers; their dependencies have to be installed and listed
alongside them.
2026-11-06 16:22:03 +01:00
Alex J ee02866730 fix(mail): check buffer length before reading TNEF properties
Several places in the TNEF attachment decoder read a fixed number of
bytes, or index at a fixed offset, out of a MAPI property's data buffer
without checking the buffer is actually that large:

- the possibly-embedded-TNEF signature, read at offset 16 for an object
  property and at offset 0 for plain file data
- the same object-attachment data, when building the actual attachment
  content a few lines later: the length used there is derived from the
  same unchecked offset and underflows to a huge value for a short buffer
- the classification flag, read as an 8-byte value
- the recurrence pattern, indexed up to offset 0x23 but only checked for
  0x1F bytes

A short enough attachment property made these read, or in the attachment
case allocate, past the end of the buffer.

Add the missing length checks; where no further data is left to build
from, skip that part of the output instead.
2026-11-06 16:21:03 +01:00
Hivert Quentin 328c96cdd6 fix(sql): properly parse name in contact lookup part 2 2026-11-01 20:04:17 +01:00
Hivert Quentin 03ac106c21 fix(sql): properly parse name in contact lookup 2026-11-01 12:45:49 +01:00
Hivert Quentin 8c50b84d8d fix(tool): fix name of subscribe folder by setting the context 2026-10-27 15:50:08 +01:00
Hivert Quentin 370a4a433c feat(acccount): Add read only account 2026-10-21 09:33:37 +02:00
Hivert Quentin 01f545b0b3 fix(ldap): properly escape ldap input 2026-10-14 17:28:04 +02:00
Hivert Quentin 0b71116c95 fix(draft): check the name of the draft 2026-10-14 11:07:46 +02:00
Hivert Quentin 868ecbea55 fix(user): check session key value before using it 2026-10-14 10:46:50 +02:00
Hivert Quentin 981df7b2fc fix(pwd): fix 0 value for password policy 2026-10-09 11:08:40 +02:00
Hadrien Blanc 20779cf353 fix(mail): sanitize the domain part of generated message-ids
generateMessageID: appended the substring following the last '@'
without sanitizing it, so a sender value such as 'Doe, John <a@b>'
produced 'Message-Id: <uuid@b>>' with a duplicated closing bracket on
calendar invitations. A nil domain also left the message-id
unterminated.

The domain part is now cut at the first address delimiter or
whitespace - a domain is a single token, and anything else would
allow header injection through generated message-ids.

Fixes #6201
2026-10-07 11:13:33 +02:00
smizrahi be3630d009 fix(mail): Keep content of Outlook downlevel-revealed conditional comments. Fixes #6167. 2026-10-02 17:25:02 +02:00
Hivert Quentin 012e6eff47 fix(junk): extend list of junk icon available 2026-09-14 10:56:28 +02:00
Hivert Quentin 04a3e98238 fix(pwd): use the proper url for reset password mail part2 2026-09-10 08:11:23 +02:00
Hivert Quentin 3f4f949664 feat(junk): add junk action on mail view 2026-09-04 18:13:36 +02:00
Hivert Quentin 10dc173349 fix(sanitization): update regex for html sanitization 2026-09-03 10:51:45 +02:00
Jan Kahmen 8813677ecb fix(core): keep the @import cleanup working in stringWithoutHTMLInjection
the trailing while loop reuses the regex variable, which by then points at the
angular brace pattern whenever stripAngular is YES. that pattern has two
capture groups while the loop substitutes $1@im****$3, so NSRegularExpression
raises NSInvalidArgumentException and the NS_HANDLER swallows it.

give the @import pattern its own variable and use it in both the replacement
and the loop. the replacement also used the template of the block above, which
dropped the whole style element instead of masking the @import in place, so
test_stringWithoutHTMLInjection failed. it passes again, and a case with
stripAngular YES covers the loop.
2026-08-17 23:03:41 +02:00
Hivert Quentin f7fce46371 chore(release): 5.12.10 2026-08-13 10:17:59 +02:00
Hivert Quentin 2a8f20e080 i18n(hu): Update Hungarian translations 2026-08-13 10:03:55 +02:00
Hivert Quentin f0c23407bf chore(sendmail): disable sendmail for now 2026-08-11 17:34:50 +02:00
Hivert Quentin 1caa25711f fix(bug): incorrect method called 2026-08-11 17:06:27 +02:00
Hivert Quentin 47133fdf3b fix(mail): escape angularJS directive for description 2026-08-10 19:34:25 +02:00
Hivert Quentin 3a78a3bbb4 fix(calendar): do not transmit og http status to external calendar 2026-06-09 10:26:58 +02:00
smizrahi f11f34cdef fix(mail): escape References/Organization/Newsgroups headers in HTML forward so message-id chevrons aren't parsed as HTML tags hiding the quoted body. Closes #6046. 2026-06-04 11:53:58 +02:00
Hivert Quentin b18f1a09f5 fix(event): clean import of event 2026-05-26 10:30:02 +02:00
Hivert Quentin c45233c11e fix(pref): prevent onevent cleaning to remove legitimate words 2026-05-19 09:30:58 +02:00
Hivert Quentin 93b82a0f60 fix(openid): check the userinfo mail + avoid infinite loop 2026-05-05 10:39:38 +02:00
Hivert Quentin 67ce01ec2a fix(mail): sanitise mail with ics (invitation to event) 2026-05-03 15:08:15 +02:00
Hivert Quentin d902756aaf fix(acl): fix folder path 2026-04-21 13:52:19 +02:00
Hivert Quentin f9b71059f4 fix(acl): only add existing uid 2026-04-20 09:08:40 +02:00
Hivert Quentin d7f02b6083 fix(typo): pass the correct arg to checkLogin 2026-03-26 09:07:05 +01:00
Hivert Quentin 1f7e5d2b2c fix(sql): use proper sql adaptor for usr source 2026-03-24 15:26:37 +01:00
Hivert Quentin 1fdb4d3026 i18n(pt): Add Greek (partial) 2026-03-02 15:01:52 +01:00
Hivert Quentin d993227b36 i18n(th): Update Thai translations 2026-03-02 11:49:54 +01:00
Hivert Quentin 83d4c522f8 fix(vulnerability): properly change the totp code after disabling it 2026-02-25 15:23:57 +01:00
Hivert Quentin 389e8e64c4 fix(ui): prevent UI to search for users with empty string 2026-01-29 15:58:00 +01:00
Hivert Quentin 95efe73e69 fix(encryptedUrl): fix cache key data and expect uncrypted name for freebusy 2025-12-22 17:28:49 +01:00
Hivert Quentin 981748754a fix(mailer): don't add mailto: to string starting with @ 2025-09-24 09:18:08 +02:00
Hivert Quentin a7f7950d91 fix(eas): use proper imap mech for EAS request when using openid 2025-09-19 16:47:16 +02:00
Hivert Quentin 5d616600df feat(mail): Add a setting to show the attachments above the mail body 2025-09-19 15:30:45 +02:00
Hivert Quentin 0fb3db0608 fix(label): ensure the translation kept is not null 2025-09-16 16:09:01 +02:00
Hivert Quentin a7651e56c5 fix(task): fix reminder for tasks 2025-09-15 17:21:47 +02:00
Emily Kooistra 481a9bf1de perf(calendar): don't allocate and copy all children for each time we call _filterComponent:
Improving the filtering of the calender objects, keeping a global static of the array of tags
that are allowed. And using removeChildren to prevent the need of a full copy while we iterate
over it.
2025-09-15 15:43:05 +02:00
Emily Kooistra f48f27c812 perf(core): store translations in a globally static NSMutableDictionary
fetching public ICS files without this patch result in continual opening
and closing of the "Localizable.strings" to create a NSDictionary,
looking up one key and closing it again. By caching it in a static
variable this greatly improves the performance.
2025-09-15 15:43:05 +02:00
Hivert Quentin 86d94ab8fe fix(log): remove the ics from the log line 2025-08-27 10:19:42 +02:00
Hivert Quentin dfcbbba514 chore(build): remove unnecessary import 2025-07-29 13:50:52 +02:00
Hivert Quentin 7bee193413 fix(mail): preoperly generates the message-id header value 2025-07-28 17:40:14 +02:00
Hivert Quentin 4ef79e219c fix(openid): correcly type userTokenInterval 2025-07-28 16:08:17 +02:00
Hivert Quentin 736d7589b1 fix(ldap): fetch the correct user source when creating an event with an attendee 2025-07-28 13:52:15 +02:00
Hivert Quentin c8dd5535b3 fix(sieveà: Sieve use the correct imap auth mechanism 2025-07-24 15:03:30 +02:00