Commit Graph

862 Commits

Author SHA1 Message Date
Oneric 31f90bbb52 Register APNG MIME type
The newest git HEAD of MIME already knows about APNG, but this
hasn’t been released yet. Without this, APNG attachments from
remote posts won’t display as images in frontends.

Fixes: akkoma#657
2024-03-26 15:44:44 -01:00
Oneric bcc528b2e2 Never automatically assign privileged content types
By mapping all extensions related to our custom privileged types
back to innocuous text/plain, our custom types will never automatically
be inserted which was one of the factors making impersonation possible.

Note, this does not invalidate the upload and emoji Content-Type
restrictions from previous commits. Apart from counterfeit AP objects
there are other payloads with standard types this protects against,
e.g. *.js Javascript payloads as used in prior frontend injections.
2024-03-18 22:33:10 -01:00
Oneric 0ec62acb9d Always insert Dedupe upload filter
This actually was already intended before to eradict all future
path-traversal-style exploits and to fix issues with some
characters like akkoma#610 in 0b2ec0ccee. However, Dedupe and
AnonymizeFilename got mixed up. The latter only anonymises the name
in Content-Disposition headers GET parameters (with link_name),
_not_ the upload path.

Even without Dedupe, the upload path is prefixed by an UUID,
so it _should_ already be hard to guess for attackers. But now
we actually can be sure no path shenanigangs occur, uploads
reliably work and save some disk space.

While this makes the final path predictable, this prediction is
not exploitable. Insertion of a back-reference to the upload
itself requires pulling off a successfull preimage attack against
SHA-256, which is deemed infeasible for the foreseeable futures.

Dedupe was already included in the default list in config.exs
since 28cfb2c37a, but this will get overridde by whatever the
config generated by the "pleroma.instance gen" task chose.

Upload+delete tests running in parallel using Dedupe might be flaky, but
this was already true before and needs its own commit to fix eventually.
2024-03-18 22:33:10 -01:00
Oneric f7c9793542 Sanitise Content-Type of uploads
The lack thereof enables spoofing ActivityPub objects.

A malicious user could upload fake activities as attachments
and (if having access to remote search) trick local and remote
fedi instances into fetching and processing it as a valid object.

If uploads are hosted on the same domain as the instance itself,
it is possible for anyone with upload access to impersonate(!)
other users of the same instance.
If uploads are exclusively hosted on a different domain, even the most
basic check of domain of the object id and fetch url matching should
prevent impersonation. However, it may still be possible to trick
servers into accepting bogus users on the upload (sub)domain and bogus
notes attributed to such users.
Instances which later migrated to a different domain and have a
permissive redirect rule in place can still be vulnerable.
If — like Akkoma — the fetching server is overly permissive with
redirects, impersonation still works.

This was possible because Plug.Static also uses our custom
MIME type mappings used for actually authentic AP objects.

Provided external storage providers don’t somehow return ActivityStream
Content-Types on their own, instances using those are also safe against
their users being spoofed via uploads.

Akkoma instances using the OnlyMedia upload filter
cannot be exploited as a vector in this way — IF the
fetching server validates the Content-Type of
fetched objects (Akkoma itself does this already).

However, restricting uploads to only multimedia files may be a bit too
heavy-handed. Instead this commit will restrict the returned
Content-Type headers for user uploaded files to a safe subset, falling
back to generic 'application/octet-stream' for anything else.
This will also protect against non-AP payloads as e.g. used in
past frontend code injection attacks.

It’s a slight regression in user comfort, if say PDFs are uploaded,
but this trade-off seems fairly acceptable.

(Note, just excluding our own custom types would offer no protection
 against non-AP payloads and bear a (perhaps small) risk of a silent
 regression should MIME ever decide to add a canonical extension for
 ActivityPub objects)

Now, one might expect there to be other defence mechanisms
besides Content-Type preventing counterfeits from being accepted,
like e.g. validation of the queried URL and AP ID matching.
Inserting a self-reference into our uploads is hard, but unfortunately
*oma does not verify the id in such a way and happily accepts _anything_
from the same domain (without even considering redirects).
E.g. Sharkey (and possibly other *keys) seem to attempt to guard
against this by immediately refetching the object from its ID, but
this is easily circumvented by just uploading two payloads with the
ID of one linking to the other.

Unfortunately *oma is thus _both_ a vector for spoofing and
vulnerable to those spoof payloads, resulting in an easy way
to impersonate our users.

Similar flaws exists for emoji and media proxy.

Subsequent commits will fix this by rigorously sanitising
content types in more areas, hardening our checks, improving
the default config and discouraging insecure config options.
2024-03-18 22:33:10 -01:00
Oneric 8f1776a8a7 Purge leftovers from FollowBot MRF
It was dropped in 9db4c2429f
2024-02-19 23:13:05 +01:00
Oneric 3b0714c4fd Fix SimplePolicy blocking account updates
ci/woodpecker/pr/build-amd64 Pipeline is pending Details
ci/woodpecker/pr/build-arm64 Pipeline is pending Details
ci/woodpecker/pr/docs Pipeline is pending Details
ci/woodpecker/pr/lint Pipeline is pending Details
ci/woodpecker/pr/test Pipeline is pending Details
This fixes an oversight in e99e2407f3
which added background_removal as a possible SimplePolicy setting.
However, it did _not_ add a default value to the base config and
as it turns out instance_list doesn’t handle unset options well.

In effect this caused federating instances with SimplePolicy enabled
but background_removal not explicitly configured to always trip up for
outgoing account updates in check_background_removal (and incoming
updates from Sharkey).
For added ""fun"" this error was able to block account updates made
e.g. via /api/v1/accounts/update_credentials.

Tests were unaffected since they explicitly override
all relevant config options.

Set a default to avoid all this
(note to self: don’t forget next time, baka!)
2024-02-17 03:10:05 +01:00
Oneric 5f7d47dcb7 Drop obolete chat/shoutbox config options
Their functions were purged in 0f132b802d
2024-02-11 05:15:02 +01:00
FloatingGhost 6cb40bee26 Migrate to phoenix 1.7 (#626)
ci/woodpecker/push/lint Pipeline was successful Details
ci/woodpecker/push/test Pipeline was successful Details
ci/woodpecker/push/build-arm64 Pipeline was successful Details
ci/woodpecker/push/build-amd64 Pipeline was successful Details
ci/woodpecker/push/docs Pipeline was successful Details
Closes #612

Co-authored-by: tusooa <tusooa@kazv.moe>
Reviewed-on: #626
Co-authored-by: FloatingGhost <hannah@coffee-and-dreams.uk>
Co-committed-by: FloatingGhost <hannah@coffee-and-dreams.uk>
2023-08-15 10:22:18 +00:00
FloatingGhost e59fc0677b Update mime dep 2023-08-07 04:07:42 +01:00
XxXCertifiedForkliftDriverXxX 07b478dc49 Implement blocklists for MediaProxy
ci/woodpecker/pr/woodpecker Pipeline is pending Details
2023-06-26 15:18:31 +02:00
FloatingGhost 037f881187 Fix create processing in direct message disabled 2023-05-23 13:16:20 +01:00
FloatingGhost f2b4e7f86b Merge branch 'develop' of akkoma.dev:AkkomaGang/akkoma into develop
ci/woodpecker/push/woodpecker Pipeline is pending Details
2023-04-14 17:56:56 +01:00
floatingghost 8c86a06ed1 Merge pull request 'Remove "default" image description' (#493) from ilja/akkoma:remove_default_image_description into develop
ci/woodpecker/push/woodpecker Pipeline is pending Details
Reviewed-on: #493
2023-04-14 16:27:41 +00:00
FloatingGhost 4c9c959bb3 Merge branch 'develop' into frontend-switcher-9000 2023-04-14 16:56:10 +01:00
sadposter 0151ca1d52 Revert "Remove indexer plugin"
ci/woodpecker/push/woodpecker Pipeline is pending Details
ci/woodpecker/pr/woodpecker Pipeline is pending Details
This reverts commit 1d94f2a424.
2023-03-29 03:32:30 +01:00
FloatingGhost 1d94f2a424 Remove indexer plugin
ci/woodpecker/push/woodpecker Pipeline is pending Details
2023-03-29 01:59:19 +01:00
FloatingGhost dd44387f1a Add timeline visibility options 2023-03-17 15:33:28 +00:00
FloatingGhost 3d964a9970 Add frontend preference route 2023-03-12 23:24:07 +00:00
ilja 6c396fcab4 Remove "default" image description
ci/woodpecker/pr/woodpecker Pipeline is pending Details
When no image description is filled in, Pleroma allowed fallbacks.
Those were (based on a setting) either the filename, or a fixed description.
Neither are good options for image descriptions imo, so here we remove this.

Note that there's two tests removed who supposedly tested something else.
But examining closer, they didn't seem to test what they claimed to test,
so I removed them rather than try to "fix" them.
2023-03-12 08:42:33 +01:00
Seirdy 676cc0d0d7
Make default outgoing-blocks setting off
This should help mitigate negative impacts related to block-retaliation
and block-circumvention when blocks become visible to the blocked party.
Instances interested in broadcasting blocks can turn this on if they
wish. This should have always been the default.

See also: AkkomaGang/akkoma-fe#274
2023-01-26 22:01:22 -08:00
ilja c092fc9fd6 Add translation module for Argos Translate (#351)
ci/woodpecker/push/woodpecker Pipeline is pending Details
Argos Translate is a Python module for translation and can be used as a command line tool.

This is also the engine for LibreTranslate, for which we already have a module.
Here we can use the engine directly from our server without doing requests to a third party or having to install our own LibreTranslate webservice (obviously you do have to install Argos Translate).

One thing that's currently still missing from Argos Translate is auto-detection of languages (see <https://github.com/argosopentech/argos-translate/issues/9>). For now, when no source language is provided, we just return the text unchanged, supposedly translated from the target language. That way you get a near immediate response in pleroma-fe when clicking Translate, after which you can select the source language from a dropdown.

Argos Translate also doesn't seem to handle html very well. Therefore we give admins the option to strip the html before translating. I made this an option because I'm unsure if/how this will change in the future.

Co-authored-by: ilja <git@ilja.space>
Reviewed-on: #351
Co-authored-by: ilja <akkoma.dev@ilja.space>
Co-committed-by: ilja <akkoma.dev@ilja.space>
2022-12-19 13:06:39 +00:00
FloatingGhost dcac8adb3d Add option to modify HTTP pool size
ci/woodpecker/push/woodpecker Pipeline was successful Details
2022-12-16 18:33:00 +00:00
FloatingGhost 126f1ca69c increase rich media backoff time
ci/woodpecker/push/woodpecker Pipeline is pending Details
2022-12-16 17:31:04 +00:00
Paul Dawson eb9ef59d50 Remove legacy references to FE that is not officially supported
ci/woodpecker/pr/woodpecker Pipeline is pending Details
2022-12-16 08:08:00 -06:00
FloatingGhost 48d302a60f allow disabling prometheus entirely
ci/woodpecker/push/woodpecker Pipeline is pending Details
2022-12-16 11:17:04 +00:00
FloatingGhost f752126427 Remove quack, ensure adapter is finch
ci/woodpecker/push/woodpecker Pipeline is pending Details
2022-12-11 23:22:35 +00:00
FloatingGhost affc910372 Remove hackney/gun in favour of finch 2022-12-11 19:19:31 +00:00
FloatingGhost 6f83ae27aa extend reject MRF to check if originating instance is blocked 2022-12-09 19:57:29 +00:00
floatingghost db60640c5b Fixing up deletes a bit (#327)
ci/woodpecker/push/woodpecker Pipeline failed Details
Co-authored-by: FloatingGhost <hannah@coffee-and-dreams.uk>
Reviewed-on: #327
2022-12-01 15:00:53 +00:00
floatingghost 0703c1826b Merge pull request 'change default allow_relay to false' (#309) from nocebo/akkoma:default-no-relay into develop
ci/woodpecker/push/woodpecker Pipeline is pending Details
Reviewed-on: #309
2022-11-25 09:57:01 +00:00
astra akari ca35a4c835 change default allow_relay to false
ci/woodpecker/pr/woodpecker Pipeline is pending Details
relay functionality should be opt-in
2022-11-25 00:45:32 +00:00
floatingghost 2fe1484ed3 http timeout config (#307)
ci/woodpecker/push/woodpecker Pipeline was successful Details
Ref https://meta.akkoma.dev/t/increase-timeout-on-libretranslate-request-how/156/2

Co-authored-by: FloatingGhost <hannah@coffee-and-dreams.uk>
Reviewed-on: #307
2022-11-24 12:27:16 +00:00
FloatingGhost de1bbc0281 Add conversationDisplay to settings
ci/woodpecker/push/woodpecker Pipeline was successful Details
2022-11-20 22:21:56 +00:00
@r3g_5z@plem.sapphic.site 0e4c201f8d HTTP header improvements (#294)
ci/woodpecker/push/woodpecker Pipeline is pending Details
- Drop Expect-CT

Expect-CT has been redundant since 2018 when Certificate Transparency became mandated and required for all CAs and browsers. This header is only implemented in Chrome and is now deprecated. HTTP header analysers do not check this anymore as this is enforced by default. See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Expect-CT

- Raise HSTS to 2 years and explicitly preload

The longer age for HSTS, the better. Header analysers prefer 2 years over 1 year now as free TLS is very common using Let's Encrypt.
For HSTS to be fully effective, you need to submit your root domain (domain.tld) to https://hstspreload.org. However, a requirement for this is the "preload" directive in Strict-Transport-Security. If you do not have "preload", it will reject your domain.

- Drop X-Download-Options

This is an IE8-era header when Adobe products used to use the IE engine for making outbound web requests to embed webpages in things like Adobe Acrobat (PDFs). Modern apps are using Microsoft Edge WebView2 or Chromium Embedded Framework. No modern browser checks or header analyser check for this.

- Set base-uri to 'none'

This is to specify the domain for relative links (`<base>` HTML tag). pleroma-fe does not use this and it's an incredibly niche tag.

I use all of these myself on my instance by rewriting the headers with zero problems. No breakage observed.

I have not compiled my Elixr changes, but I don't see why they'd break.

Co-authored-by: r3g_5z <june@terezi.dev>
Reviewed-on: #294
Co-authored-by: @r3g_5z@plem.sapphic.site <june@terezi.dev>
Co-committed-by: @r3g_5z@plem.sapphic.site <june@terezi.dev>
2022-11-20 21:20:06 +00:00
floatingghost c1127e321b Add configurable timeline per oban job (#273)
ci/woodpecker/push/woodpecker Pipeline is pending Details
Heavily inspired by https://git.pleroma.social/pleroma/pleroma/-/merge_requests/3777

Co-authored-by: FloatingGhost <hannah@coffee-and-dreams.uk>
Reviewed-on: #273
2022-11-13 23:55:51 +00:00
astra akari 35cddd7cf7 change default redirectRootNoLogin to /main/public
ci/woodpecker/pr/woodpecker Pipeline is pending Details
close #268
2022-11-13 08:43:12 +00:00
floatingghost b7e8ce2350 Scrape instance nodeinfo (#251)
ci/woodpecker/push/woodpecker Pipeline is pending Details
Co-authored-by: FloatingGhost <hannah@coffee-and-dreams.uk>
Reviewed-on: #251
2022-11-06 22:49:39 +00:00
Norm 9682ec4c5f Change default instance name to "Akkoma"
ci/woodpecker/pr/woodpecker Pipeline is pending Details
This was left at "Pleroma" for some reason.
2022-11-01 20:52:17 +00:00
FloatingGhost 856c57208b Ensure deletes are handled after everything else
ci/woodpecker/push/woodpecker Pipeline was successful Details
ci/woodpecker/pr/woodpecker Pipeline was successful Details
2022-10-11 14:30:08 +01:00
floatingghost c6e63aaf6b Backend settings sync (#226)
ci/woodpecker/push/woodpecker Pipeline was successful Details
Co-authored-by: FloatingGhost <hannah@coffee-and-dreams.uk>
Reviewed-on: #226
2022-10-06 16:22:15 +00:00
lou_de_sel 8fe59d495d Update soapbox base url
ci/woodpecker/pr/woodpecker Pipeline is pending Details
At some point 'soapbox-pub/soapbox-fe' was moved to 'soapbox-pub/soapbox' and the build url is now updated.
2022-09-18 07:45:30 +00:00
FloatingGhost ad1a6d3dc2 ensure queue_target can't be silly low
ci/woodpecker/push/woodpecker Pipeline was successful Details
2022-09-16 14:23:31 +01:00
FloatingGhost 7759187de9 ensure default value is sane
ci/woodpecker/push/woodpecker Pipeline was successful Details
2022-08-29 22:20:47 +01:00
floatingghost df39cab9c1 Automatic status translation (#187)
ci/woodpecker/push/woodpecker Pipeline was successful Details
Fixes #115

Co-authored-by: FloatingGhost <hannah@coffee-and-dreams.uk>
Reviewed-on: #187
2022-08-29 19:42:22 +00:00
FloatingGhost 85137f591f Add ability to obfuscate domains in MRF transparency
ci/woodpecker/push/woodpecker Pipeline was successful Details
ci/woodpecker/pr/woodpecker Pipeline was successful Details
2022-08-27 11:57:57 +01:00
floatingghost e4f2251e0f Add support for setting language in instance metadata (#183)
ci/woodpecker/push/woodpecker Pipeline was successful Details
Reviewed-on: #183
2022-08-25 16:11:21 +00:00
floatingghost 11ec9daa5b API compatibility with fedibird, frontend config (#163)
ci/woodpecker/push/woodpecker Pipeline failed Details
Reviewed-on: #163
2022-08-17 00:22:59 +00:00
FloatingGhost 55179d4214 set soapbox-fe v2 by default
ci/woodpecker/push/woodpecker Pipeline is pending Details
fixes #157
2022-08-11 10:25:03 +01:00
floatingghost ca000f8301 Merge mrf_simple-reject with quarantine (#137)
ci/woodpecker/push/woodpecker Pipeline was successful Details
Reviewed-on: #137
2022-08-02 14:19:24 +00:00
Joel Beckmeyer e26388a01c Support reaching user@sub.domain.tld at user@domain.tld (#134)
ci/woodpecker/push/woodpecker Pipeline was successful Details
Reviewed-on: #134
Co-authored-by: Joel Beckmeyer <joel@beckmeyer.us>
Co-committed-by: Joel Beckmeyer <joel@beckmeyer.us>
2022-08-02 13:54:22 +00:00