Skip to content

@ character is no longer supported in SMB domain, username or password #9794

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

Closed
smitsjelle opened this issue Jan 28, 2025 · 0 comments
Closed

Comments

@smitsjelle
Copy link
Contributor

In what version(s) of Spring Integration are you seeing this issue?
6.4.1

Describe the bug
With the introduction of the fix of GH-9711 that uses the new rawUrl method (thanks for the solution there by the way), I noticed that some existing connections suddenly were unauthorized. On investigation, it appeared that the common denominator is that in the cases of the connection breaking, the password contained an @ character. With the way the underlying JCIFS library calls the URL constructor, it will trigger the java.net.Url code to look for indexOf('@'). When the URL resulting from the rawUrl method would be smb://sambaguest:samb@[email protected]:445/smb share, java.net.URL will interpret the host part as empty string (see screencap below). This (obviously) subsequently yields a UnknownHostException.

Image

To Reproduce

Add the following lines to the existing SmbMessageHistoryTests#testMessageHistory method, it will fail on the assertion:

CIFSContext context = new BaseContext(new PropertyConfiguration(new Properties()));
URL rawUrl = new URL(null, smbSessionFactory.rawUrl(true), context.getUrlHandler());
assertThat(rawUrl.getHost()).isEqualTo("localhost");

Expected behavior

The @ character can be used in the domain, username or password as it could before the fix.

@smitsjelle smitsjelle added status: waiting-for-triage The issue need to be evaluated and its future decided type: bug labels Jan 28, 2025
smitsjelle added a commit to smitsjelle/spring-integration that referenced this issue Jan 28, 2025
…d password

Fixes: spring-projects#9794

The `SmbConfig.rawUrl()` method doesn't apply any URL encoding, resulting in parts of the `domainUserPass` that may contain a `@` character to break the URL logic in regard to determining the hostname.

* Modify `SmbConfig.getDomainUserPass(_includePassword)` to conditionally encode the variables. Makes sure to encode the individual parts to not undesirably encode the `;` and `:` characters, breaking other logic.
* Modify `SmbConfig.rawUrl(_includePassword)` and `SmbConfig.createUri(_includePassword)` to call the modified method with the correct `_urlEncode` variable

Signed-off-by: Jelle Smits <[email protected]>
@artembilan artembilan added in: smb for: backport-to-6.3.x for: backport-to-6.4.x and removed status: waiting-for-triage The issue need to be evaluated and its future decided labels Jan 28, 2025
@artembilan artembilan added this to the 6.5.0-M2 milestone Jan 28, 2025
artembilan pushed a commit that referenced this issue Jan 28, 2025
Fixes: #9794
Issue link: #9794

The `SmbConfig.rawUrl()` method doesn't apply any URL encoding,
resulting in parts of the `domainUserPass` that may contain a `@` character to break
the URL logic in regard to determining the hostname.

* Modify `SmbConfig.getDomainUserPass(_includePassword)` to conditionally encode the variables.
Makes sure to encode the individual parts to not undesirably encode the `;` and `:` characters, breaking other logic.
* Modify `SmbConfig.rawUrl(_includePassword)` and `SmbConfig.createUri(_includePassword)`
to call the modified method with the correct `_urlEncode` variable

Signed-off-by: Jelle Smits <[email protected]>

[[email protected]: some code cleanup]

* Add author to the affected classes
* Remove redundant explicit exceptions list from the `SmbMessageHistoryTests`

**Auto-cherry-pick to `6.3.x`**

Signed-off-by: Artem Bilan <[email protected]>
spring-builds pushed a commit that referenced this issue Jan 28, 2025
Fixes: #9794
Issue link: #9794

The `SmbConfig.rawUrl()` method doesn't apply any URL encoding,
resulting in parts of the `domainUserPass` that may contain a `@` character to break
the URL logic in regard to determining the hostname.

* Modify `SmbConfig.getDomainUserPass(_includePassword)` to conditionally encode the variables.
Makes sure to encode the individual parts to not undesirably encode the `;` and `:` characters, breaking other logic.
* Modify `SmbConfig.rawUrl(_includePassword)` and `SmbConfig.createUri(_includePassword)`
to call the modified method with the correct `_urlEncode` variable

Signed-off-by: Jelle Smits <[email protected]>

[[email protected]: some code cleanup]

* Add author to the affected classes
* Remove redundant explicit exceptions list from the `SmbMessageHistoryTests`

Signed-off-by: Artem Bilan <[email protected]>
(cherry picked from commit fcd90a9)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants