Commit graph

1007 commits

Author SHA1 Message Date
Denis Kasak
131f7cfd71 Fix off-by-one comparison error when unpickling uint32_t. 2021-07-31 01:27:43 +00:00
Denis Kasak
bdd73c5c32 Fix unpickling error handling. 2021-07-31 01:27:43 +00:00
Denis Kasak
34974551ab unpickle_account: Add error checking to the harness. 2021-07-31 01:27:43 +00:00
Denis Kasak
0a8bbde361 Support building a "disarmed" target via the OLM_FUZZING macro.
Like other crypto libs, libolm contains many obstacles which a fuzzer is
unlikely to be able to surmount but which are not important for the end
goal of fuzzing. The easiest and most robust way around this is to remove
these obstacles conditionally when building the fuzzer binaries.

This commit adds a preprocessor macro OLM_FUZZING which can be used to
conditionally disables problematic bits of code during compile-time for
easier fuzzing.

Currently the only thing it disables is the encryption/decryption and
base64 encoding/decoding when processing pickled Megolm keys. This
allows the fuzzers to fuzz the unpickling functionality directly without
inadvertently fuzzing the base64 encoder and encryption (which should be
fuzzed separately).

The macro is set in the Makefile *only* when building fuzzer binaries.
2021-07-13 13:51:16 +02:00
Denis Kasak
b38e282f3a fuzzing: Add script for starting fuzzers on a given harness. 2021-07-13 13:49:18 +02:00
Denis Kasak
ceed90922a fuzzing: Add readme. 2021-07-13 13:49:18 +02:00
Denis Kasak
4d14750c38 Move fuzzers under fuzzing/ dir. 2021-07-13 13:49:18 +02:00
Denis Kasak
e06ac20558 Add unpickle_megolm_outbound fuzzer. Enable C harness support. 2021-07-13 11:13:15 +00:00
Denis Kasak
811e56a0f0 Add lib_exports.sh for printing list of exported functions.
Prints the list of exported functions from a built library object.
Useful for sanity checking.
2021-07-13 10:50:27 +02:00
Denis Kasak
583f8b761b Add some more files to .gitignore
- `compile_commands.json`: clang compilation database
- `.ccls-cache`: Cache directory for the ccls language server
- `.clang-format`: clang formatting description
2021-07-12 16:58:11 +02:00
Denis Kasak
84dbba8e1c Makefile: Remove debugging flag from the release target. 2021-07-12 16:50:34 +02:00
Denis Kasak
a44fc368f2 Makefile: Fix passing optimization flag to fuzzing builds. 2021-07-12 16:50:06 +02:00
Denis Kasak
93352b55e7 fuzz_group_decrypt: Enable AFL++ persistent mode. 2021-07-12 15:48:27 +02:00
Denis Kasak
7dd4c77c19 Add .editorconfig.
See https://editorconfig.org/ for more information.
2021-07-08 14:28:40 +00:00
Denis Kasak
4901435a0e Improve cleanup in fuzzing harnesses 2021-07-08 14:23:55 +00:00
Johannes Hayeß
254a4a5619 Fix building of tests with MSVC
Hi,

currently tests don't build with MSVC, because the Base64 test tries to initialize multiple arrays with a length value that was derived from a non-const context. I have fixed this by using vectors instead.

Sincerely

Johannes Hayeß

From 2d76972a862f0aa04b5011537bef71a49aa82a03 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Johannes=20Haye=C3=9F?= <jhaye@mailbox.org>
Date: Sun, 27 Jun 2021 17:46:24 +0200
Subject: [PATCH] Fix compiling with MSVC
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Previously attempts to initialize arrays with non-const value. This
seemingly works on GCC/clang due to their static code analysis, but
fails with MSVC. This switches to dynamic memory allocation with
std::vector, to solve the problem.

Signed-off-by: Johannes Hayeß <jhaye@mailbox.org>
2021-06-29 13:14:05 -04:00
Hubert Chathi
abf8f97491 fix JavaScript build 2021-06-18 13:12:11 -04:00
Hubert Chathi
0f7c13334f install error.h when using make too 2021-06-17 15:26:46 -04:00
Hubert Chathi
2aad86ea84 fix Python build 2021-06-17 11:56:08 -04:00
Denis Kasak
9a8b421903 Update dart-olm URL. 2021-06-17 16:20:48 +02:00
Hubert Chathi
37c8e14e53 make functions const where possible 2021-06-16 23:22:25 -04:00
Hubert Chathi
7263c4221b add functions to get the error codes rather than error strings 2021-06-16 22:40:14 -04:00
Hubert Chathi
60be1ca55f add support file for cross-compiling Windows library 2021-06-16 15:28:30 -04:00
Hubert Chathi
1b7973626e only export olm functions to avoid colliding with other libraries 2021-06-16 15:05:19 -04:00
Hubert Chathi
d47c2a92b8 make new pickle/unpickle function 2021-06-09 14:59:31 +00:00
Hubert Chathi
4803f4192d make (de)serialize methods public in OlmAccount 2021-06-09 14:59:31 +00:00
Hubert Chathi
3612ac7ae7 add missing dependency in Makefile for javascript/olm_prefix.js 2021-06-08 14:57:05 -04:00
Denis Kasak
b90f9ee7d3 Fix typo in docstring (repeated word). 2021-06-04 22:24:15 +00:00
Denis Kasak
6ed8d687e8 Document olm_create_inbound_session_from properly.
The old docstring was the same as olm_create_inbound_session and didn't
explain the difference between them.
2021-06-04 22:24:15 +00:00
Denis Kasak
3e6592e445 Compile ASAN and MSAN versions of fuzzer harnesses too. 2021-06-02 14:02:19 +02:00
Denis Kasak
56df2613f3 Switch to afl-clang-fast(++).
This type of instrumentation is much faster (several times over) and
supports much more features than afl-gcc/afl-g++, though it requires
a LLVM/clang installation.
2021-06-02 14:02:19 +02:00
Hubert Chathi
64afab9364 prepare for release 2021-06-01 13:44:45 -04:00
Benoit Marty
995def932e Fix issue with Jitpack build 2021-05-28 18:12:50 +02:00
Hubert Chathi
d856c441b6 use Python 3 2021-05-24 10:32:57 -04:00
Hubert Chathi
22bc1155ed prepare for release 2021-05-24 10:29:24 -04:00
Hubert Chathi
891a5f22c8 fix path 2021-05-24 10:27:28 -04:00
Denis Kasak
ccc0d122ee olm_pk_decrypt: Ensure inputs are of correct length. 2021-05-24 15:50:14 +02:00
Denis Kasak
2f35e0bc61 olm_sas_set_their_key: Fail early on invalid base64. 2021-05-24 15:50:14 +02:00
Denis Kasak
e82f2601b0 Fail decoding base64 of invalid length.
olm::decode_base64 now returns the length of the raw decoded data on
success. When given input with an invalid base64 length, it fails early
(before decoding any input) and returns -1.

This also makes the C function _olm_decode_base64 an actual binding of
olm::decode_base64 instead of a wrapper with slightly different
behaviour.
2021-05-24 15:50:14 +02:00
Denis Kasak
a5efc08ef3 olm: Also initialize all fields when decoding Olm messages.
As a precaution.
2021-05-11 13:32:23 +02:00
Denis Kasak
c325db02fc megolm: Fix use of uninitialized value in group message decoding.
_olm_decode_group_message should initialize all fields of the results
struct before returning. This is because its caller
_decrypt_max_plaintext_length relies on it having initialized these
fields.

Luckily, this only allows one to subvert the version check in
_decrypt_max_plaintext_length, but not the following check that the
ciphertext field is non-null because that field *is* initialized.
2021-05-11 13:23:19 +02:00
Denis Kasak
0a7b6da9a0 Slightly refactor/comment the harness for clarity. 2021-05-10 21:04:44 +00:00
Denis Kasak
8d1cfd207a Fix a fuzzing harness double free when input is of size 0.
Consider the case when the input is size 0. In this case, `count` and
`buffer_pos` will be 0 as well. The `realloc` call in the `count == 0`
branch will then effectively become a free.

However, `realloc` can sometimes return `NULL` when a 0 is passed for
the size. The current code assumes that this only happens on a memory
allocation error and breaks out of the loop. This then becomes a double
free because the buffer is freed a second time, causing an abort.

The intent of the `realloc` is probably to downsize the buffer to fit
the data exactly in order to make incorrect memory access more obvious.
This commit skips this downsizing if the size of the input data is 0.
2021-05-10 21:04:44 +00:00
Arun Babu Neelicattu
15f65283c7 make: Replace deprecated emcc configuration
EXTRA_EXPORTED_RUNTIME_METHODS is deprecated. Replace with
EXPORTED_RUNTIME_METHODS.
2021-05-10 20:40:42 +00:00
Arun Babu Neelicattu
0684eb4564 ci: add initial build pipeline 2021-05-10 20:40:42 +00:00
Arun Babu Neelicattu
b0a05976ea python: remove tox basepython configuration 2021-05-10 20:40:42 +00:00
Hubert Chathi
18ad6cb067 Merge branch 'fix-ncc-audit-url' into 'master'
Fix URL to the NCC Group audit.

See merge request matrix-org/olm!22
2021-05-04 21:58:35 +00:00
Hubert Chathi
d7c3971f9a update release instructions 2021-05-04 17:54:05 -04:00
Denis Kasak
c95677611c Fix URL to the NCC Group audit.
The original URL is now redirecting to a generic listing page and there
are no links to the actual Olm audit paper there.
2021-05-04 15:09:29 +02:00
Lukas Lihotzki
7f53dedca6 Declare olm_sas_calculate_mac_fixed_base64 in header
Signed-off-by: Lukas Lihotzki <lukas@lihotzki.de>
2021-04-27 16:18:33 -04:00