matrix-rust-sdk-fuzz-target

git clone git://archive.git.mtrnord.blog/MTRNord/matrix-rust-sdk-fuzz-target.git
Log | Files | Refs | README

commit 7ba51ab9dae9ed981c4d8dd81d318204e6effa99
parent 42520ec5168b370e5b2a2633a5df3b2d4e7c05ea
Author: MTRNord <mtrnord1@gmail.com>
Date:   Tue, 29 Jun 2021 00:52:30 +0200

Various improvements

Diffstat:
A.cargo/config.toml | 3+++
MCargo.lock | 39++++++++++++++++++++++++++++++++++++---
MCargo.toml | 12+++++++++---
Adendrite_test_env/config/dendrite.yaml | 346+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Adendrite_test_env/config/matrix_key.pem | 5+++++
Adendrite_test_env/config/server.crt | 28++++++++++++++++++++++++++++
Adendrite_test_env/config/server.key | 51+++++++++++++++++++++++++++++++++++++++++++++++++++
Adendrite_test_env/docker-compose.deps.yml | 42++++++++++++++++++++++++++++++++++++++++++
Adendrite_test_env/docker-compose.yml | 21+++++++++++++++++++++
Adendrite_test_env/postgres/create_db.sh | 5+++++
Adendrite_test_env/run.sh | 3+++
Ain/registration/1 | 2++
Ain/registration/2 | 2++
Ain/registration/3 | 2++
Ain/registration/4 | 2++
Ain/registration/5 | 2++
Msrc/get_room.rs | 12+++++-------
Msrc/main.rs | 8+++-----
Asrc/register_user.rs | 25+++++++++++++++++++++++++
19 files changed, 592 insertions(+), 18 deletions(-)

diff --git a/.cargo/config.toml b/.cargo/config.toml @@ -0,0 +1,2 @@ +[registries] +ktra = { index = "ssh://git@gitlab.com/MTRNord/personal-rust-registry.git" } +\ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock @@ -52,9 +52,9 @@ dependencies = [ [[package]] name = "afl" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d16d691836db1a0927dab30b21add058acec42e177534128e7f00a7cf60bafc2" +version = "0.11.1" +source = "registry+ssh://git@gitlab.com/MTRNord/personal-rust-registry.git" +checksum = "75ae3b4ebe6458c2aee1da34d7c700e6292023d82de2b501892b2688484e9d12" dependencies = [ "cc", "clap", @@ -80,6 +80,12 @@ dependencies = [ ] [[package]] +name = "arbitrary" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "237430fd6ed3740afe94eefcc278ae21e050285be882804e0d6e8695f0c94691" + +[[package]] name = "assign" version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1030,7 +1036,9 @@ name = "matrix-rust-sdk-fuzz-target" version = "0.1.0" dependencies = [ "afl", + "arbitrary", "matrix-sdk", + "tokio", "url", ] @@ -2116,6 +2124,15 @@ dependencies = [ ] [[package]] +name = "signal-hook-registry" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e51e73328dc4ac0c7ccbda3a494dfa03df1de2f46018127f60c693f2648455b0" +dependencies = [ + "libc", +] + +[[package]] name = "signature" version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -2390,11 +2407,27 @@ dependencies = [ "libc", "memchr", "mio", + "num_cpus", + "once_cell", + "parking_lot", "pin-project-lite", + "signal-hook-registry", + "tokio-macros", "winapi", ] [[package]] +name = "tokio-macros" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c49e3df43841dafb86046472506755d8501c5615673955f6aa17181125d13c37" +dependencies = [ + "proc-macro2 1.0.27", + "quote 1.0.9", + "syn 1.0.73", +] + +[[package]] name = "tokio-native-tls" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" diff --git a/Cargo.toml b/Cargo.toml @@ -6,13 +6,19 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -afl = { version = "0.10.0", features = ["reset_lazy_static"] } +afl = { version = "0.11", features = ["reset_lazy_static"], registry = "ktra" } matrix-sdk = "0.3.0" url = "2.2.2" +tokio = { version = "1", features = ["full"] } +arbitrary = { version = "1"} [patch.crates-io] lazy_static = { git = "https://github.com/rust-fuzz/resettable-lazy-static.rs" } [[bin]] name = "fuzz_get_room" -path = "src/get_room.rs" -\ No newline at end of file +path = "src/get_room.rs" + +[[bin]] +name = "fuzz_registration" +path = "src/register_user.rs" +\ No newline at end of file diff --git a/dendrite_test_env/config/dendrite.yaml b/dendrite_test_env/config/dendrite.yaml @@ -0,0 +1,346 @@ +# This is the Dendrite configuration file. +# +# The configuration is split up into sections - each Dendrite component has a +# configuration section, in addition to the "global" section which applies to +# all components. +# +# At a minimum, to get started, you will need to update the settings in the +# "global" section for your deployment, and you will need to check that the +# database "connection_string" line in each component section is correct. +# +# Each component with a "database" section can accept the following formats +# for "connection_string": +# SQLite: file:filename.db +# file:///path/to/filename.db +# PostgreSQL: postgresql://user:pass@hostname/database?params=... +# +# SQLite is embedded into Dendrite and therefore no further prerequisites are +# needed for the database when using SQLite mode. However, performance with +# PostgreSQL is significantly better and recommended for multi-user deployments. +# SQLite is typically around 20-30% slower than PostgreSQL when tested with a +# small number of users and likely will perform worse still with a higher volume +# of users. +# +# The "max_open_conns" and "max_idle_conns" settings configure the maximum +# number of open/idle database connections. The value 0 will use the database +# engine default, and a negative value will use unlimited connections. The +# "conn_max_lifetime" option controls the maximum length of time a database +# connection can be idle in seconds - a negative value is unlimited. + +# The version of the configuration file. +version: 1 + +# Global Matrix configuration. This configuration applies to all components. +global: + # The domain name of this homeserver. + server_name: example.com + + # The path to the signing private key file, used to sign requests and events. + private_key: matrix_key.pem + + # The paths and expiry timestamps (as a UNIX timestamp in millisecond precision) + # to old signing private keys that were formerly in use on this domain. These + # keys will not be used for federation request or event signing, but will be + # provided to any other homeserver that asks when trying to verify old events. + # old_private_keys: + # - private_key: old_matrix_key.pem + # expired_at: 1601024554498 + + # How long a remote server can cache our server signing key before requesting it + # again. Increasing this number will reduce the number of requests made by other + # servers for our key but increases the period that a compromised key will be + # considered valid by other homeservers. + key_validity_period: 168h0m0s + + # Lists of domains that the server will trust as identity servers to verify third + # party identifiers such as phone numbers and email addresses. + trusted_third_party_id_servers: + - matrix.org + - vector.im + + disable_federation: true + + # Configuration for Kafka/Naffka. + kafka: + # List of Kafka broker addresses to connect to. This is not needed if using + # Naffka in monolith mode. + addresses: + - kafka:9092 + + # The prefix to use for Kafka topic names for this homeserver. Change this only if + # you are running more than one Dendrite homeserver on the same Kafka deployment. + topic_prefix: Dendrite + + # Whether to use Naffka instead of Kafka. This is only available in monolith + # mode, but means that you can run a single-process server without requiring + # Kafka. + use_naffka: false + + # Naffka database options. Not required when using Kafka. + naffka_database: + connection_string: postgresql://dendrite:itsasecret@postgres/dendrite_naffka?sslmode=disable + max_open_conns: 10 + max_idle_conns: 2 + conn_max_lifetime: -1 + + # Configuration for Prometheus metric collection. + metrics: + # Whether or not Prometheus metrics are enabled. + enabled: false + + # HTTP basic authentication to protect access to monitoring. + basic_auth: + username: metrics + password: metrics + + # DNS cache options. The DNS cache may reduce the load on DNS servers + # if there is no local caching resolver available for use. + dns_cache: + # Whether or not the DNS cache is enabled. + enabled: false + + # Maximum number of entries to hold in the DNS cache, and + # for how long those items should be considered valid in seconds. + cache_size: 256 + cache_lifetime: 300 + +# Configuration for the Appservice API. +app_service_api: + internal_api: + listen: http://0.0.0.0:7777 + connect: http://appservice_api:7777 + database: + connection_string: postgresql://dendrite:itsasecret@postgres/dendrite_appservice?sslmode=disable + max_open_conns: 10 + max_idle_conns: 2 + conn_max_lifetime: -1 + + # Appservice configuration files to load into this homeserver. + config_files: [] + +# Configuration for the Client API. +client_api: + internal_api: + listen: http://0.0.0.0:7771 + connect: http://client_api:7771 + external_api: + listen: http://0.0.0.0:8071 + + # Prevents new users from being able to register on this homeserver, except when + # using the registration shared secret below. + registration_disabled: false + + # If set, allows registration by anyone who knows the shared secret, regardless of + # whether registration is otherwise disabled. + registration_shared_secret: "" + + # Whether to require reCAPTCHA for registration. + enable_registration_captcha: false + + # Settings for ReCAPTCHA. + recaptcha_public_key: "" + recaptcha_private_key: "" + recaptcha_bypass_secret: "" + recaptcha_siteverify_api: "" + + # TURN server information that this homeserver should send to clients. + turn: + turn_user_lifetime: "" + turn_uris: [] + turn_shared_secret: "" + turn_username: "" + turn_password: "" + + # Settings for rate-limited endpoints. Rate limiting will kick in after the + # threshold number of "slots" have been taken by requests from a specific + # host. Each "slot" will be released after the cooloff time in milliseconds. + rate_limiting: + enabled: true + threshold: 5 + cooloff_ms: 500 + +# Configuration for the EDU server. +edu_server: + internal_api: + listen: http://0.0.0.0:7778 + connect: http://edu_server:7778 + +# Configuration for the Federation API. +federation_api: + internal_api: + listen: http://0.0.0.0:7772 + connect: http://federation_api:7772 + external_api: + listen: http://0.0.0.0:8072 + + # List of paths to X.509 certificates to be used by the external federation listeners. + # These certificates will be used to calculate the TLS fingerprints and other servers + # will expect the certificate to match these fingerprints. Certificates must be in PEM + # format. + federation_certificates: [] + +# Configuration for the Federation Sender. +federation_sender: + internal_api: + listen: http://0.0.0.0:7775 + connect: http://federation_sender:7775 + database: + connection_string: postgresql://dendrite:itsasecret@postgres/dendrite_federationsender?sslmode=disable + max_open_conns: 10 + max_idle_conns: 2 + conn_max_lifetime: -1 + + # How many times we will try to resend a failed transaction to a specific server. The + # backoff is 2**x seconds, so 1 = 2 seconds, 2 = 4 seconds, 3 = 8 seconds etc. + send_max_retries: 16 + + # Disable the validation of TLS certificates of remote federated homeservers. Do not + # enable this option in production as it presents a security risk! + disable_tls_validation: false + + # Use the following proxy server for outbound federation traffic. + proxy_outbound: + enabled: false + protocol: http + host: localhost + port: 8080 + +# Configuration for the Key Server (for end-to-end encryption). +key_server: + internal_api: + listen: http://0.0.0.0:7779 + connect: http://key_server:7779 + database: + connection_string: postgresql://dendrite:itsasecret@postgres/dendrite_keyserver?sslmode=disable + max_open_conns: 10 + max_idle_conns: 2 + conn_max_lifetime: -1 + +# Configuration for the Media API. +media_api: + internal_api: + listen: http://0.0.0.0:7774 + connect: http://media_api:7774 + external_api: + listen: http://0.0.0.0:8074 + database: + connection_string: postgresql://dendrite:itsasecret@postgres/dendrite_mediaapi?sslmode=disable + max_open_conns: 10 + max_idle_conns: 2 + conn_max_lifetime: -1 + + # Storage path for uploaded media. May be relative or absolute. + base_path: /var/dendrite/media + + # The maximum allowed file size (in bytes) for media uploads to this homeserver + # (0 = unlimited). + max_file_size_bytes: 10485760 + + # Whether to dynamically generate thumbnails if needed. + dynamic_thumbnails: false + + # The maximum number of simultaneous thumbnail generators to run. + max_thumbnail_generators: 10 + + # A list of thumbnail sizes to be generated for media content. + thumbnail_sizes: + - width: 32 + height: 32 + method: crop + - width: 96 + height: 96 + method: crop + - width: 640 + height: 480 + method: scale + +# Configuration for the Room Server. +room_server: + internal_api: + listen: http://0.0.0.0:7770 + connect: http://room_server:7770 + database: + connection_string: postgresql://dendrite:itsasecret@postgres/dendrite_roomserver?sslmode=disable + max_open_conns: 10 + max_idle_conns: 2 + conn_max_lifetime: -1 + +# Configuration for the Server Key API (for server signing keys). +signing_key_server: + internal_api: + listen: http://0.0.0.0:7780 + connect: http://signing_key_server:7780 + database: + connection_string: postgresql://dendrite:itsasecret@postgres/dendrite_signingkeyserver?sslmode=disable + max_open_conns: 10 + max_idle_conns: 2 + conn_max_lifetime: -1 + + # Perspective keyservers to use as a backup when direct key fetches fail. This may + # be required to satisfy key requests for servers that are no longer online when + # joining some rooms. + key_perspectives: + - server_name: matrix.org + keys: + - key_id: ed25519:auto + public_key: Noi6WqcDj0QmPxCNQqgezwTlBKrfqehY1u2FyWP9uYw + - key_id: ed25519:a_RXGa + public_key: l8Hft5qXKn1vfHrg3p4+W8gELQVo8N13JkluMfmn2sQ + + # This option will control whether Dendrite will prefer to look up keys directly + # or whether it should try perspective servers first, using direct fetches as a + # last resort. + prefer_direct_fetch: false + +# Configuration for the Sync API. +sync_api: + internal_api: + listen: http://0.0.0.0:7773 + connect: http://sync_api:7773 + external_api: + listen: http://0.0.0.0:8073 + database: + connection_string: postgresql://dendrite:itsasecret@postgres/dendrite_syncapi?sslmode=disable + max_open_conns: 10 + max_idle_conns: 2 + conn_max_lifetime: -1 + +# Configuration for the User API. +user_api: + internal_api: + listen: http://0.0.0.0:7781 + connect: http://user_api:7781 + account_database: + connection_string: postgresql://dendrite:itsasecret@postgres/dendrite_userapi_accounts?sslmode=disable + max_open_conns: 10 + max_idle_conns: 2 + conn_max_lifetime: -1 + device_database: + connection_string: postgresql://dendrite:itsasecret@postgres/dendrite_userapi_devices?sslmode=disable + max_open_conns: 10 + max_idle_conns: 2 + conn_max_lifetime: -1 + +# Configuration for Opentracing. +# See https://github.com/matrix-org/dendrite/tree/master/docs/tracing for information on +# how this works and how to set it up. +tracing: + enabled: false + jaeger: + serviceName: "" + disabled: false + rpc_metrics: false + tags: [] + sampler: null + reporter: null + headers: null + baggage_restrictions: null + throttler: null + +# Logging configuration, in addition to the standard logging that is sent to +# stdout by Dendrite. +logging: +- type: file + level: info + params: + path: /var/log/dendrite diff --git a/dendrite_test_env/config/matrix_key.pem b/dendrite_test_env/config/matrix_key.pem @@ -0,0 +1,5 @@ +-----BEGIN MATRIX PRIVATE KEY----- +Key-ID: ed25519:9Y5kAq + +AqoJKTCaTWETIJTACvDEStavsWdSU7hsU99SnTN2Rfo= +-----END MATRIX PRIVATE KEY----- diff --git a/dendrite_test_env/config/server.crt b/dendrite_test_env/config/server.crt @@ -0,0 +1,28 @@ +-----BEGIN CERTIFICATE----- +MIIEwDCCAqigAwIBAgIRAMNJ4zZmX7NFPs6zBT+g5+kwDQYJKoZIhvcNAQELBQAw +ADAeFw0yMTA2MjgxNjI1MjdaFw0zMTA2MjYxNjI1MjdaMAAwggIiMA0GCSqGSIb3 +DQEBAQUAA4ICDwAwggIKAoICAQDRxJ2iC9ooqN18eif3bBePLxmgROmr9fdA8/ca +BSCA9XpGju/N3+TDlykTHnEtnDs3Mm36x+2qtRki48kJ65SVgQg6YEiy+kszJsyZ +o0xZ98VRnZqcv7tXRDvSrXr4wJlyikbiDqYPem2W8O2UFCPbsErKY6vfPsnVzA+q +fxMSpmC8xjl5/FtE83UCxfV911tU9SHnLdf4aBPCc8E2ESXEbzvbQL2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3cNOlv5Ufsles9jdilZP3ZwRhNHb7Qyd0SvUR64oFQCHMYRq +iU98dmObIMXNcd3FxRwjoh43VLoJWYslQonZVQzs1TRV5BaCysn6FSmJdFck5vQ3 +E6ue+WbTzqCZuN7cE5kBfd2p6Gl6dl4ZqV0IGqiQadFfbUNDDCvsLEt2jD0DOz/L +kVSxesPRCkdmKwZkMmDBLwmSHT4= +-----END CERTIFICATE----- diff --git a/dendrite_test_env/config/server.key b/dendrite_test_env/config/server.key @@ -0,0 +1,51 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIJKQIBAAKCAgEA0cSdogvaKKjdfHon92wXjy8ZoETpq/X3QPP3GgUggPV6Ro7v +zd/kw5cpEx5xLZw7NzJt+sftqrUZIuPJCeuUlYEIOmBIsvpLMybMmaNMWffFUZ2a +nL+7V0Q70q16+MCZcopG4g6mD3ptlvDtlBQj27BKymOr3z7J1cwPqn8TEqZgvMY5 +efxbRPN1AsX1fddbVPUh5y3X+GgTwnPBNhElxG8720C9ovg8Bo7Kh8purZj3t5ec +WYfkgHTLxJ1U+vFPCleqgI7uoTWJZ4F8fXb2AZApiJ0REMjlX/xpzgfdQtRp5keF +tvX8nnisqqYSgvokj3eXMC10VQ+Z020wfxygqXKy97NCziLA2fCZb2ASGKYyBzFT +FNVqWAUQnQ4GlaDwxFTwImlMDBm9zpTxhRBUGmUHlZSF4qrZr4JDAiL2jdx6cQvx +M6FMVO5KynKURJSrnpDH//fc42CzV1C+0rHjUcqHmVVjj5xzyL/n5+OVSqC8sa57 +2XMaj2y/akA8c6emhlVVpcdUGRUaR7okU4OiQ4LNp/6W8Rs6ZQKLAm5V1Bv8UaVs +Z5HsAvM6PfjtUHspjqFylZJREnW+zjP8GktWBHZEGDp1Y6laUa510LSLJLG6LlEl +w6Pqm35/UifhHaY+y97+05XbY91aVUZURf35/Wt6LvV7VKoNpyILA624590CAwEA +AQKCAgEAxQT4UST0qE/Ch5FsTFU344IHfaJ8HskMi/MYWVYLa1QknnTOAv2R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DoVIbl34t +R8IfNx9NYDGc+eZ8b1+/ee+IsZ0QwMF061QrJOfRsyTA97dRU+8lUl4u+OE0yS/h +m17/Goqjd0V4QWlkoOlzj/dn9d9WO6wF4XWigH56hvWQ091Ig1NoaJJdnqhbR+ki +tbNE0B+BdTT4Nk0USAO1jmtok0oeFbXKHFb7Lg3oufHcHwlti55AzU9givWJe23g +fckpGj2t9D3TlVAhsEY2EfjqV7YS9+dFejj5AE0CJ2uC2AAV35gxjXZg3NZw +-----END RSA PRIVATE KEY----- diff --git a/dendrite_test_env/docker-compose.deps.yml b/dendrite_test_env/docker-compose.deps.yml @@ -0,0 +1,42 @@ +version: "3.4" +services: + # PostgreSQL is needed for both polylith and monolith modes. + postgres: + hostname: postgres + image: postgres:11 + restart: always + volumes: + - ./postgres/create_db.sh:/docker-entrypoint-initdb.d/20-create_db.sh + # To persist your PostgreSQL databases outside of the Docker image, to + # prevent data loss, you will need to add something like this: + # - ./path/to/persistent/storage:/var/lib/postgresql/data + environment: + POSTGRES_PASSWORD: itsasecret + POSTGRES_USER: dendrite + networks: + - internal + + # Zookeeper is only needed for polylith mode! + zookeeper: + hostname: zookeeper + image: zookeeper + networks: + - internal + + # Kafka is only needed for polylith mode! + kafka: + container_name: dendrite_kafka + hostname: kafka + image: wurstmeister/kafka + environment: + KAFKA_ADVERTISED_HOST_NAME: "kafka" + KAFKA_DELETE_TOPIC_ENABLE: "true" + KAFKA_ZOOKEEPER_CONNECT: "zookeeper:2181" + depends_on: + - zookeeper + networks: + - internal + +networks: + internal: + attachable: true diff --git a/dendrite_test_env/docker-compose.yml b/dendrite_test_env/docker-compose.yml @@ -0,0 +1,21 @@ +version: "3.4" +services: + monolith: + hostname: monolith + image: matrixdotorg/dendrite-monolith:latest + command: [ + "--tls-cert=server.crt", + "--tls-key=server.key" + ] + ports: + - 8888:8008 + - 8889:8448 + volumes: + - ./config:/etc/dendrite + - ./media:/var/dendrite/media + networks: + - internal + +networks: + internal: + attachable: true diff --git a/dendrite_test_env/postgres/create_db.sh b/dendrite_test_env/postgres/create_db.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +for db in userapi_accounts userapi_devices mediaapi syncapi roomserver signingkeyserver keyserver federationsender appservice naffka; do + createdb -U dendrite -O dendrite dendrite_$db +done diff --git a/dendrite_test_env/run.sh b/dendrite_test_env/run.sh @@ -0,0 +1,3 @@ +#!/bin/bash +docker-compose -f docker-compose.deps.yml up -d postgres +docker-compose up diff --git a/in/registration/1 b/in/registration/1 @@ -0,0 +1 @@ +MTRNord +\ No newline at end of file diff --git a/in/registration/2 b/in/registration/2 @@ -0,0 +1 @@ +poljar +\ No newline at end of file diff --git a/in/registration/3 b/in/registration/3 @@ -0,0 +1 @@ +tuli +\ No newline at end of file diff --git a/in/registration/4 b/in/registration/4 @@ -0,0 +1 @@ +tenhundret +\ No newline at end of file diff --git a/in/registration/5 b/in/registration/5 @@ -0,0 +1 @@ +cat +\ No newline at end of file diff --git a/src/get_room.rs b/src/get_room.rs @@ -4,13 +4,11 @@ use matrix_sdk::{identifiers::RoomId, Client}; use url::Url; fn main() { - afl::fuzz!(|data: &[u8]| { - if let Ok(s) = std::str::from_utf8(data) { - if let Ok(url) = Url::parse("http://127.0.0.1") { - if let Ok(client) = Client::new(url) { - if let Ok(room_id) = RoomId::try_from(s) { - let _ = client.get_room(&room_id); - } + afl::fuzz!(|data: &str| { + if let Ok(url) = Url::parse("http://127.0.0.1") { + if let Ok(client) = Client::new(url) { + if let Ok(room_id) = RoomId::try_from(data) { + let _ = client.get_room(&room_id); } } } diff --git a/src/main.rs b/src/main.rs @@ -2,11 +2,9 @@ use matrix_sdk::Client; use url::Url; fn main() { - afl::fuzz!(|data: &[u8]| { - if let Ok(s) = std::str::from_utf8(data) { - if let Ok(url) = Url::parse(&s) { - let _ = Client::new(url); - } + afl::fuzz!(|data: &str| { + if let Ok(url) = Url::parse(&data) { + let _ = Client::new(url); } }); } diff --git a/src/register_user.rs b/src/register_user.rs @@ -0,0 +1,25 @@ +use matrix_sdk::api::r0::account::register::Request as RegistrationRequest; +use matrix_sdk::api::r0::uiaa::AuthData; +use matrix_sdk::{assign, Client}; +use tokio::runtime::Runtime; +use url::Url; + +fn main() { + afl::fuzz!(|data: (&str, &str, &str)| { + let (username, password, session) = data; + if let Ok(url) = Url::parse("http://127.0.0.1:8888") { + if let Ok(client) = Client::new(url) { + let request = assign!(RegistrationRequest::new(), { + username: Some(username), + password: Some(password), + auth: Some(AuthData::FallbackAcknowledgement { session }), + }); + + let rt = Runtime::new().unwrap(); + rt.block_on(async move { + let _ = client.register(request).await; + }); + } + } + }); +}