Skip to content

Commit

Permalink
Correct missing password hash removal
Browse files Browse the repository at this point in the history
Auth has removal was broken in a number of cases for all 4.2 versions:
- All queries that returned the object text for a mntner when
  all hash names (MD5-PW etc.) in the text were lower or mixed case
- Queries for the auth attribute in GraphQL queries
- Queries for the objectText for journal entries in GraphQL queries

Further details in 4.2.3 release notes.

Note that this commit only has the fix and tests or coverage may
fail without the subsequent update to the tests.
  • Loading branch information
mxsasha committed Mar 31, 2022
1 parent c752ea5 commit 0e41bae
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion irrd/server/graphql/resolvers.py
Expand Up @@ -187,6 +187,8 @@ def resolve_rpsl_object_journal(rpsl_object, info: GraphQLResolveInfo):
response['operation'] = response['operation'].name
if response['origin']:
response['origin'] = response['origin'].name
if response['objectText']:
response['objectText'] = remove_auth_hashes(response['objectText'])
yield response


Expand Down Expand Up @@ -221,7 +223,7 @@ def _rpsl_db_query_to_graphql_out(query: RPSLDatabaseQuery, info: GraphQLResolve
object_type = resolve_rpsl_object_type(row)
for key, value in row.get('parsed_data', dict()).items():
if key == 'auth':
value = remove_auth_hashes(value)
value = [remove_auth_hashes(v) for v in value]
graphql_type = schema.graphql_types[object_type][key]
if graphql_type == 'String' and isinstance(value, list):
value = '\n'.join(value)
Expand Down
3 changes: 2 additions & 1 deletion irrd/utils/text.py
Expand Up @@ -12,7 +12,8 @@ def remove_auth_hashes(input: Optional[str]):
if not input:
return input
# If there are no hashes, skip the RE for performance.
if not any([pw_hash in input for pw_hash in PASSWORD_HASHERS_ALL.keys()]):
input_lower = input.lower()
if not any([pw_hash.lower() in input_lower for pw_hash in PASSWORD_HASHERS_ALL.keys()]):
return input
return re_remove_passwords.sub(r'\1 %s # Filtered for security' % PASSWORD_HASH_DUMMY_VALUE, input)

Expand Down

0 comments on commit 0e41bae

Please sign in to comment.