Skip to content

fix: search terms for binary fields will be converted if possible#815

Open
jvillafanez wants to merge 2 commits into
masterfrom
attr_converter_in_search
Open

fix: search terms for binary fields will be converted if possible#815
jvillafanez wants to merge 2 commits into
masterfrom
attr_converter_in_search

Conversation

@jvillafanez

@jvillafanez jvillafanez commented Nov 21, 2023

Copy link
Copy Markdown
Member

Related to https://github.com/owncloud/enterprise/issues/6032

The app will take care of converting binary attributes when searching for them.

For example, if the user_ldap app has been configured the "user search attributes" with "objectguid" (among other attributes), searching by "36E271F3" might return results, assuming the converted value we have from binary contains those characters.
Note that the converted value will also be stored as search term for the account in the "oc_account_terms" table.

@jvillafanez

Copy link
Copy Markdown
Member Author

Failing tests are known: #814

@jvillafanez

Copy link
Copy Markdown
Member Author

I don't think I can add tests for the changes in the Access class easily. Need to change attributes in the connection class, which are accessed using magic methods. It doesn't seem possible to mock those.

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Passed Quality Gate passed

The SonarCloud Quality Gate passed, but some issues were introduced.

2 New issues
0 Security Hotspots
17.4% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud

@pako81

pako81 commented Jun 17, 2024

Copy link
Copy Markdown

merge this?

@jvillafanez jvillafanez force-pushed the attr_converter_in_search branch from fdc668b to 4b25d15 Compare June 17, 2024 09:05
@sonarqubecloud

Copy link
Copy Markdown

@dj4oC dj4oC left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Adds binary-attribute conversion (via ConverterHub) into the LDAP search-filter builders and UserEntry::getSearchTerms(), so binary attributes like objectguid can be searched by their string form.

Findings

Security/correctness — needs human verification before merge (LDAP attribute mapping is a never-auto-fix zone):

  • In both getAdvancedFilterPartForSearch() and getFilterPartForSearch(), the converted value is escaped a second time: $this->prepareSearchTerm($converterHub->str2filter($attr, $word)). If str2filter() already returns an LDAP-filter-safe encoded form (e.g. a \hh\hh\hh-style hex escape for binary GUIDs, which is the standard way to filter on binary attributes per RFC 4515), then running that through a generic prepareSearchTerm() escaper again risks double-escaping the backslashes and corrupting the filter — likely breaking the search silently (filter would just never match) rather than being exploitable, but it should be confirmed against a real LDAP directory/mock, not just the unit test in this diff, which only exercises bin2str() on the read path (UserEntryTest::testGetSearchTermsWithConversion), not the filter-building path with the double-escape.
  • No test covers getAdvancedFilterPartForSearch()/getFilterPartForSearch() with a converter-backed attribute — the one new test only covers getSearchTerms().

Stability: the catch (ConverterException $e) fallback paths look correct (fall back to the unconverted, still-escaped term rather than failing the whole search).

Verdict

Commenting, not blocking outright — but per policy, LDAP attribute-conversion/mapping changes need a maintainer to confirm the filter round-trips correctly against a real directory (or a filter-level test) before merge, given the double-escape risk above.

🤖 Automated review by Claude Code (security · stability · performance · coverage)


Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants