Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into joriks/opentracing…
Browse files Browse the repository at this point in the history
…_e2e
  • Loading branch information
JorikSchellekens committed Aug 5, 2019
2 parents 82d6eb1 + 8ed9e63 commit a68119e
Show file tree
Hide file tree
Showing 94 changed files with 1,395 additions and 419 deletions.
5 changes: 3 additions & 2 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,15 @@ steps:


- command:
- "python -m pip install tox"
- "apt-get update && apt-get install -y python3.5 python3.5-dev python3-pip libxml2-dev libxslt-dev zlib1g-dev"
- "python3.5 -m pip install tox"
- "tox -e py35-old,codecov"
label: ":python: 3.5 / SQLite / Old Deps"
env:
TRIAL_FLAGS: "-j 2"
plugins:
- docker#v3.0.1:
image: "python:3.5"
image: "ubuntu:xenial" # We use xenail to get an old sqlite and python
propagate-environment: true
retry:
automatic:
Expand Down
3 changes: 1 addition & 2 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
comment:
layout: "diff"
comment: off

coverage:
status:
Expand Down
43 changes: 42 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,48 @@
Synapse 1.2.1 (2019-07-26)
==========================

Security update
---------------

This release includes *four* security fixes:

- Prevent an attack where a federated server could send redactions for arbitrary events in v1 and v2 rooms. ([\#5767](https://github.com/matrix-org/synapse/issues/5767))
- Prevent a denial-of-service attack where cycles of redaction events would make Synapse spin infinitely. Thanks to `@lrizika:matrix.org` for identifying and responsibly disclosing this issue. ([0f2ecb961](https://github.com/matrix-org/synapse/commit/0f2ecb961))
- Prevent an attack where users could be joined or parted from public rooms without their consent. Thanks to @dylangerdaly for identifying and responsibly disclosing this issue. ([\#5744](https://github.com/matrix-org/synapse/issues/5744))
- Fix a vulnerability where a federated server could spoof read-receipts from
users on other servers. Thanks to @dylangerdaly for identifying this issue too. ([\#5743](https://github.com/matrix-org/synapse/issues/5743))

Additionally, the following fix was in Synapse **1.2.0**, but was not correctly
identified during the original release:

- It was possible for a room moderator to send a redaction for an `m.room.create` event, which would downgrade the room to version 1. Thanks to `/dev/ponies` for identifying and responsibly disclosing this issue! ([\#5701](https://github.com/matrix-org/synapse/issues/5701))

Synapse 1.2.0 (2019-07-25)
==========================

No significant changes.


Synapse 1.2.0rc2 (2019-07-24)
=============================

Bugfixes
--------

- Fix a regression introduced in v1.2.0rc1 which led to incorrect labels on some prometheus metrics. ([\#5734](https://github.com/matrix-org/synapse/issues/5734))


Synapse 1.2.0rc1 (2019-07-22)
=============================

Security fixes
--------------

This update included a security fix which was initially incorrectly flagged as
a regular bug fix.

- It was possible for a room moderator to send a redaction for an `m.room.create` event, which would downgrade the room to version 1. Thanks to `/dev/ponies` for identifying and responsibly disclosing this issue! ([\#5701](https://github.com/matrix-org/synapse/issues/5701))

Features
--------

Expand All @@ -26,7 +68,6 @@ Bugfixes
- Fix bug in #5626 that prevented the original_event field from actually having the contents of the original event in a call to `/relations`. ([\#5654](https://github.com/matrix-org/synapse/issues/5654))
- Fix 3PID bind requests being sent to identity servers as `application/x-form-www-urlencoded` data, which is deprecated. ([\#5658](https://github.com/matrix-org/synapse/issues/5658))
- Fix some problems with authenticating redactions in recent room versions. ([\#5699](https://github.com/matrix-org/synapse/issues/5699), [\#5700](https://github.com/matrix-org/synapse/issues/5700), [\#5707](https://github.com/matrix-org/synapse/issues/5707))
- Ignore redactions of m.room.create events. ([\#5701](https://github.com/matrix-org/synapse/issues/5701))


Updates to the Docker image
Expand Down
1 change: 1 addition & 0 deletions changelog.d/5686.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Use `M_USER_DEACTIVATED` instead of `M_UNKNOWN` for errcode when a deactivated user attempts to login.
1 change: 1 addition & 0 deletions changelog.d/5693.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix UISIs during homeserver outage.
1 change: 1 addition & 0 deletions changelog.d/5743.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Log when we receive an event receipt from an unexpected origin.
1 change: 1 addition & 0 deletions changelog.d/5746.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Reduce database IO usage by optimising queries for current membership.
1 change: 1 addition & 0 deletions changelog.d/5749.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix some error cases in the caching layer.
1 change: 1 addition & 0 deletions changelog.d/5750.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add a prometheus metric for pending cache lookups.
1 change: 1 addition & 0 deletions changelog.d/5752.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Reduce database IO usage by optimising queries for current membership.
1 change: 1 addition & 0 deletions changelog.d/5753.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Stop trying to fetch events with event_id=None.
1 change: 1 addition & 0 deletions changelog.d/5768.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Convert RedactionTestCase to modern test style.
1 change: 1 addition & 0 deletions changelog.d/5770.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Reduce database IO usage by optimising queries for current membership.
1 change: 1 addition & 0 deletions changelog.d/5774.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Reduce database IO usage by optimising queries for current membership.
1 change: 1 addition & 0 deletions changelog.d/5775.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix debian packaging scripts to correctly build sid packages.
1 change: 1 addition & 0 deletions changelog.d/5780.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Allow looping calls to be given arguments.
1 change: 1 addition & 0 deletions changelog.d/5782.removal
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove non-functional 'expire_access_token' setting.
1 change: 1 addition & 0 deletions changelog.d/5783.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Synapse can now be configured to not join remote rooms of a given "complexity" (currently, state events) over federation. This option can be used to prevent adverse performance on resource-constrained homeservers.
1 change: 1 addition & 0 deletions changelog.d/5785.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Set the logs emitted when checking typing and presence timeouts to DEBUG level, not INFO.
1 change: 1 addition & 0 deletions changelog.d/5787.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove DelayedCall debugging from the test suite, as it is no longer required in the vast majority of Synapse's tests.
1 change: 1 addition & 0 deletions changelog.d/5789.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix UISIs during homeserver outage.
1 change: 1 addition & 0 deletions changelog.d/5790.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove some spurious exceptions from the logs where we failed to talk to a remote server.
1 change: 1 addition & 0 deletions changelog.d/5792.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Reduce database IO usage by optimising queries for current membership.
1 change: 1 addition & 0 deletions changelog.d/5793.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Reduce database IO usage by optimising queries for current membership.
1 change: 1 addition & 0 deletions changelog.d/5794.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Improve performance when making `.well-known` requests by sharing the SSL options between requests.
1 change: 1 addition & 0 deletions changelog.d/5796.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Disable codecov GitHub comments on PRs.
1 change: 1 addition & 0 deletions changelog.d/5801.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Don't allow clients to send tombstone events that reference the room it's sent in.
1 change: 1 addition & 0 deletions changelog.d/5802.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Deny redactions of events sent in a different room.
1 change: 1 addition & 0 deletions changelog.d/5804.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix check that tombstone is a state event in push rules.
1 change: 1 addition & 0 deletions changelog.d/5805.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Deny sending well known state types as non-state events.
1 change: 1 addition & 0 deletions changelog.d/5806.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix error when trying to login as a deactivated user when using a worker to handle login.
1 change: 1 addition & 0 deletions changelog.d/5807.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Allow defining HTML templates to serve the user on account renewal attempt when using the account validity feature.
1 change: 1 addition & 0 deletions changelog.d/5808.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Handle incorrectly encoded query params correctly by returning a 400.
1 change: 1 addition & 0 deletions changelog.d/5810.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Return 502 not 500 when failing to reach any remote server.
13 changes: 11 additions & 2 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
matrix-synapse-py3 (1.1.0-1) UNRELEASED; urgency=medium
matrix-synapse-py3 (1.2.1) stable; urgency=medium

* New synapse release 1.2.1.

-- Synapse Packaging team <packages@matrix.org> Fri, 26 Jul 2019 11:32:47 +0100

matrix-synapse-py3 (1.2.0) stable; urgency=medium

[ Amber Brown ]
* Update logging config defaults to match API changes in Synapse.

[ Richard van der Hoff ]
* Add Recommends and Depends for some libraries which you probably want.

-- Erik Johnston <erikj@rae> Thu, 04 Jul 2019 13:59:02 +0100
[ Synapse Packaging team ]
* New synapse release 1.2.0.

-- Synapse Packaging team <packages@matrix.org> Thu, 25 Jul 2019 14:10:07 +0100

matrix-synapse-py3 (1.1.0) stable; urgency=medium

Expand Down
5 changes: 5 additions & 0 deletions docker/Dockerfile-dhvirtualenv
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ RUN cd dh-virtualenv-1.1 && dpkg-buildpackage -us -uc -b
###
FROM ${distro}

# Get the distro we want to pull from as a dynamic build variable
# (We need to define it in each build stage)
ARG distro=""
ENV distro ${distro}

# Install the build dependencies
#
# NB: keep this list in sync with the list of build-deps in debian/control
Expand Down
3 changes: 2 additions & 1 deletion docker/build_debian.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

set -ex

DIST=`lsb_release -c -s`
# Get the codename from distro env
DIST=`cut -d ':' -f2 <<< $distro`
# we get a read-only copy of the source: make a writeable copy
cp -aT /synapse/source /synapse/build
Expand Down
31 changes: 27 additions & 4 deletions docs/sample_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,23 @@ listeners:
# Used by phonehome stats to group together related servers.
#server_context: context

# Resource-constrained Homeserver Settings
#
# If limit_remote_rooms.enabled is True, the room complexity will be
# checked before a user joins a new remote room. If it is above
# limit_remote_rooms.complexity, it will disallow joining or
# instantly leave.
#
# limit_remote_rooms.complexity_error can be set to customise the text
# displayed to the user when a room above the complexity threshold has
# its join cancelled.
#
# Uncomment the below lines to enable:
#limit_remote_rooms:
# enabled: True
# complexity: 1.0
# complexity_error: "This room is too complex."

# Whether to require a user to be in the room to add an alias to it.
# Defaults to 'true'.
#
Expand Down Expand Up @@ -785,6 +802,16 @@ uploads_path: "DATADIR/uploads"
# period: 6w
# renew_at: 1w
# renew_email_subject: "Renew your %(app)s account"
# # Directory in which Synapse will try to find the HTML files to serve to the
# # user when trying to renew an account. Optional, defaults to
# # synapse/res/templates.
# template_dir: "res/templates"
# # HTML to be displayed to the user after they successfully renewed their
# # account. Optional.
# account_renewed_html_path: "account_renewed.html"
# # HTML to be displayed when the user tries to renew an account with an invalid
# # renewal token. Optional.
# invalid_token_html_path: "invalid_token.html"

# Time that a user's session remains valid for, after they log in.
#
Expand Down Expand Up @@ -925,10 +952,6 @@ uploads_path: "DATADIR/uploads"
#
# macaroon_secret_key: <PRIVATE STRING>

# Used to enable access token expiration.
#
#expire_access_token: False

# a secret which is used to calculate HMACs for form values, to stop
# falsification of values. Must be specified for the User Consent
# forms to work.
Expand Down
2 changes: 1 addition & 1 deletion synapse/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@
except ImportError:
pass

__version__ = "1.2.0rc1"
__version__ = "1.2.1"
28 changes: 5 additions & 23 deletions synapse/api/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,21 +421,16 @@ def _parse_and_validate_macaroon(self, token, rights="access"):
try:
user_id = self.get_user_id_from_macaroon(macaroon)

has_expiry = False
guest = False
for caveat in macaroon.caveats:
if caveat.caveat_id.startswith("time "):
has_expiry = True
elif caveat.caveat_id == "guest = true":
if caveat.caveat_id == "guest = true":
guest = True

self.validate_macaroon(
macaroon, rights, self.hs.config.expire_access_token, user_id=user_id
)
self.validate_macaroon(macaroon, rights, user_id=user_id)
except (pymacaroons.exceptions.MacaroonException, TypeError, ValueError):
raise InvalidClientTokenError("Invalid macaroon passed.")

if not has_expiry and rights == "access":
if rights == "access":
self.token_cache[token] = (user_id, guest)

return user_id, guest
Expand All @@ -461,15 +456,14 @@ def get_user_id_from_macaroon(self, macaroon):
return caveat.caveat_id[len(user_prefix) :]
raise InvalidClientTokenError("No user caveat in macaroon")

def validate_macaroon(self, macaroon, type_string, verify_expiry, user_id):
def validate_macaroon(self, macaroon, type_string, user_id):
"""
validate that a Macaroon is understood by and was signed by this server.
Args:
macaroon(pymacaroons.Macaroon): The macaroon to validate
type_string(str): The kind of token required (e.g. "access",
"delete_pusher")
verify_expiry(bool): Whether to verify whether the macaroon has expired.
user_id (str): The user_id required
"""
v = pymacaroons.Verifier()
Expand All @@ -482,19 +476,7 @@ def validate_macaroon(self, macaroon, type_string, verify_expiry, user_id):
v.satisfy_exact("type = " + type_string)
v.satisfy_exact("user_id = %s" % user_id)
v.satisfy_exact("guest = true")

# verify_expiry should really always be True, but there exist access
# tokens in the wild which expire when they should not, so we can't
# enforce expiry yet (so we have to allow any caveat starting with
# 'time < ' in access tokens).
#
# On the other hand, short-term login tokens (as used by CAS login, for
# example) have an expiry time which we do want to enforce.

if verify_expiry:
v.satisfy_general(self._verify_expiry)
else:
v.satisfy_general(lambda c: c.startswith("time < "))
v.satisfy_general(self._verify_expiry)

# access_tokens include a nonce for uniqueness: any value is acceptable
v.satisfy_general(lambda c: c.startswith("nonce = "))
Expand Down
3 changes: 2 additions & 1 deletion synapse/api/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class Codes(object):
INCOMPATIBLE_ROOM_VERSION = "M_INCOMPATIBLE_ROOM_VERSION"
WRONG_ROOM_KEYS_VERSION = "M_WRONG_ROOM_KEYS_VERSION"
EXPIRED_ACCOUNT = "ORG_MATRIX_EXPIRED_ACCOUNT"
USER_DEACTIVATED = "M_USER_DEACTIVATED"


class CodeMessageException(RuntimeError):
Expand Down Expand Up @@ -151,7 +152,7 @@ def __init__(self, msg):
msg (str): The human-readable error message
"""
super(UserDeactivatedError, self).__init__(
code=http_client.FORBIDDEN, msg=msg, errcode=Codes.UNKNOWN
code=http_client.FORBIDDEN, msg=msg, errcode=Codes.USER_DEACTIVATED
)


Expand Down
6 changes: 0 additions & 6 deletions synapse/config/key.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,6 @@ def read_config(self, config, config_dir_path, **kwargs):
seed = bytes(self.signing_key[0])
self.macaroon_secret_key = hashlib.sha256(seed).digest()

self.expire_access_token = config.get("expire_access_token", False)

# a secret which is used to calculate HMACs for form values, to stop
# falsification of values
self.form_secret = config.get("form_secret", None)
Expand All @@ -144,10 +142,6 @@ def generate_config_section(
#
%(macaroon_secret_key)s
# Used to enable access token expiration.
#
#expire_access_token: False
# a secret which is used to calculate HMACs for form values, to stop
# falsification of values. Must be specified for the User Consent
# forms to work.
Expand Down
Loading

0 comments on commit a68119e

Please sign in to comment.