Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Safely parse mam retractions #3513

Merged
merged 2 commits into from
Feb 3, 2022
Merged

Safely parse mam retractions #3513

merged 2 commits into from
Feb 3, 2022

Conversation

NelsonVides
Copy link
Collaborator

With the current code, a malicious retraction could have a namespace but
then not declare any id, and in that case the function would return
{origin_id | stanza_id, none}, which breaks the contract that the
second term must be a binary. In a worst-case scenario, this could
trigger an exception later on, maybe even killing one of the MAM
async workers with their message queues if the exception is not caught.

With the current code, a malicious retraction could have a namespace but
then not declare any id, and in that case the function would return
`{origin_id | stanza_id, none}`, which breaks the contract that the
second term must be a binary. In a worst-case scenario, this could
trigger an exception later on, maybe even killing one of the MAM
async workers with their message queues if the exception is not caught.
@codecov
Copy link

codecov bot commented Jan 25, 2022

Codecov Report

Merging #3513 (4898ed3) into master (fd9e1d2) will increase coverage by 0.00%.
The diff coverage is 83.33%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #3513   +/-   ##
=======================================
  Coverage   81.02%   81.02%           
=======================================
  Files         419      419           
  Lines       32309    32310    +1     
=======================================
+ Hits        26177    26179    +2     
+ Misses       6132     6131    -1     
Impacted Files Coverage Δ
src/mam/mod_mam_utils.erl 85.89% <83.33%> (-0.60%) ⬇️
src/elasticsearch/mongoose_elasticsearch.erl 76.92% <0.00%> (-7.70%) ⬇️
src/http_upload/mod_http_upload.erl 94.62% <0.00%> (-2.16%) ⬇️
src/mam/mod_mam_elasticsearch_arch.erl 85.08% <0.00%> (-1.76%) ⬇️
src/mod_muc_log.erl 78.11% <0.00%> (ø)
...bal_distrib/mod_global_distrib_hosts_refresher.erl 73.58% <0.00%> (+1.88%) ⬆️
src/cassandra/mongoose_cassandra_worker.erl 68.54% <0.00%> (+2.81%) ⬆️
src/cassandra/mongoose_cassandra.erl 81.48% <0.00%> (+3.70%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fd9e1d2...4898ed3. Read the comment docs.

@mongoose-im
Copy link
Collaborator

mongoose-im commented Jan 25, 2022

small_tests_24 / small_tests / 590ac45
Reports root / small


small_tests_23 / small_tests / 590ac45
Reports root / small


dynamic_domains_pgsql_mnesia_23 / pgsql_mnesia / 590ac45
Reports root/ big
OK: 2691 / Failed: 0 / User-skipped: 238 / Auto-skipped: 0


dynamic_domains_pgsql_mnesia_24 / pgsql_mnesia / 590ac45
Reports root/ big
OK: 2691 / Failed: 0 / User-skipped: 238 / Auto-skipped: 0


dynamic_domains_mssql_mnesia_24 / odbc_mssql_mnesia / 590ac45
Reports root/ big
OK: 2691 / Failed: 0 / User-skipped: 238 / Auto-skipped: 0


dynamic_domains_mysql_redis_24 / mysql_redis / 590ac45
Reports root/ big
OK: 2674 / Failed: 0 / User-skipped: 255 / Auto-skipped: 0


ldap_mnesia_23 / ldap_mnesia / 590ac45
Reports root/ big
OK: 1500 / Failed: 0 / User-skipped: 390 / Auto-skipped: 0


ldap_mnesia_24 / ldap_mnesia / 590ac45
Reports root/ big
OK: 1500 / Failed: 0 / User-skipped: 390 / Auto-skipped: 0


internal_mnesia_24 / internal_mnesia / 590ac45
Reports root/ big
OK: 1541 / Failed: 0 / User-skipped: 349 / Auto-skipped: 0


pgsql_mnesia_23 / pgsql_mnesia / 590ac45
Reports root/ big
OK: 3078 / Failed: 0 / User-skipped: 247 / Auto-skipped: 0


pgsql_mnesia_24 / pgsql_mnesia / 590ac45
Reports root/ big
OK: 3078 / Failed: 0 / User-skipped: 247 / Auto-skipped: 0


elasticsearch_and_cassandra_24 / elasticsearch_and_cassandra_mnesia / 590ac45
Reports root/ big
OK: 1834 / Failed: 0 / User-skipped: 363 / Auto-skipped: 0


mssql_mnesia_24 / odbc_mssql_mnesia / 590ac45
Reports root/ big
OK: 3078 / Failed: 0 / User-skipped: 247 / Auto-skipped: 0


mysql_redis_24 / mysql_redis / 590ac45
Reports root/ big
OK: 3073 / Failed: 0 / User-skipped: 252 / Auto-skipped: 0


riak_mnesia_24 / riak_mnesia / 590ac45
Reports root/ big
OK: 1680 / Failed: 0 / User-skipped: 363 / Auto-skipped: 0

@mongoose-im
Copy link
Collaborator

mongoose-im commented Jan 25, 2022

small_tests_24 / small_tests / 4898ed3
Reports root / small


small_tests_23 / small_tests / 4898ed3
Reports root / small


dynamic_domains_pgsql_mnesia_23 / pgsql_mnesia / 4898ed3
Reports root/ big
OK: 2698 / Failed: 0 / User-skipped: 239 / Auto-skipped: 0


dynamic_domains_pgsql_mnesia_24 / pgsql_mnesia / 4898ed3
Reports root/ big
OK: 2697 / Failed: 1 / User-skipped: 239 / Auto-skipped: 0

mam_SUITE:rdbms_async_pool_mam_all:archived:metrics_incremented_for_async_pools
{error,{test_case_failed,"ASSERT EQUAL\n\tExpected false\n\tValue true\n"}}

Report log


dynamic_domains_mssql_mnesia_24 / odbc_mssql_mnesia / 4898ed3
Reports root/ big
OK: 2698 / Failed: 0 / User-skipped: 239 / Auto-skipped: 0


dynamic_domains_mysql_redis_24 / mysql_redis / 4898ed3
Reports root/ big
OK: 2681 / Failed: 0 / User-skipped: 256 / Auto-skipped: 0


internal_mnesia_24 / internal_mnesia / 4898ed3
Reports root/ big
OK: 1541 / Failed: 0 / User-skipped: 349 / Auto-skipped: 0


ldap_mnesia_23 / ldap_mnesia / 4898ed3
Reports root/ big
OK: 1500 / Failed: 0 / User-skipped: 390 / Auto-skipped: 0


ldap_mnesia_24 / ldap_mnesia / 4898ed3
Reports root/ big
OK: 1500 / Failed: 0 / User-skipped: 390 / Auto-skipped: 0


mysql_redis_24 / mysql_redis / 4898ed3
Reports root/ big
OK: 3080 / Failed: 0 / User-skipped: 253 / Auto-skipped: 0


pgsql_mnesia_24 / pgsql_mnesia / 4898ed3
Reports root/ big
OK: 3085 / Failed: 0 / User-skipped: 248 / Auto-skipped: 0


pgsql_mnesia_23 / pgsql_mnesia / 4898ed3
Reports root/ big
OK: 3085 / Failed: 0 / User-skipped: 248 / Auto-skipped: 0


elasticsearch_and_cassandra_24 / elasticsearch_and_cassandra_mnesia / 4898ed3
Reports root/ big
OK: 1834 / Failed: 0 / User-skipped: 365 / Auto-skipped: 0


riak_mnesia_24 / riak_mnesia / 4898ed3
Reports root/ big
OK: 1680 / Failed: 0 / User-skipped: 364 / Auto-skipped: 0


mssql_mnesia_24 / odbc_mssql_mnesia / 4898ed3
Reports root/ big
OK: 3085 / Failed: 0 / User-skipped: 248 / Auto-skipped: 0


dynamic_domains_pgsql_mnesia_24 / pgsql_mnesia / 4898ed3
Reports root/ big
OK: 2698 / Failed: 0 / User-skipped: 239 / Auto-skipped: 0

Copy link
Contributor

@gustawlippa gustawlippa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks nice, also some test improvements 👍

@gustawlippa gustawlippa merged commit 118686e into master Feb 3, 2022
@gustawlippa gustawlippa deleted the retraction_parsing branch February 3, 2022 09:13
@Premwoik Premwoik added this to the 5.1.0 milestone May 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants