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

Bug: Unicode in login name leads to exceptions #174

Closed
Brutus5000 opened this issue Oct 5, 2023 · 1 comment · Fixed by FAForever/db#314
Closed

Bug: Unicode in login name leads to exceptions #174

Brutus5000 opened this issue Oct 5, 2023 · 1 comment · Fixed by FAForever/db#314
Labels
good first issue Good for newcomers

Comments

@Brutus5000
Copy link
Member

Brutus5000 commented Oct 5, 2023

Log is flodded with attempts of login attempts containing unicode characters (whilst FAF only allows very strict usernames).

Unexpected exception: org.hibernate.exception.SQLGrammarException: could not execute statement [(conn=237526) Incorrect string value: '\xC5\x82.kot...' for column faf_lobby.login_log.login_string at row 1] [insert into login_log (create_time,ip,login_string,success,login_id) values (?,?,?,?,?)]
at org.hibernate.exception.internal.SQLExceptionTypeDelegate.convert(SQLExceptionTypeDelegate.java:64)
at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:56)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:108)
at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:278)
at org.hibernate.id.insert.GetGeneratedKeysDelegate.performInsert(GetGeneratedKeysDelegate.java:107)
at org.hibernate.engine.jdbc.mutation.internal.MutationExecutorPostInsertSingleTable.execute(MutationExecutorPostInsertSingleTable.java:101)
at org.hibernate.persister.entity.mutation.InsertCoordinator.doStaticInserts(InsertCoordinator.java:169)
at org.hibernate.persister.entity.mutation.InsertCoordinator.coordinateInsert(InsertCoordinator.java:111)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2757)
at org.hibernate.action.internal.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:81)
at org.hibernate.engine.spi.ActionQueue.execute(ActionQueue.java:674)
at org.hibernate.engine.spi.ActionQueue.addResolvedEntityInsertAction(ActionQueue.java:291)
at org.hibernate.engine.spi.ActionQueue.addInsertAction(ActionQueue.java:272)
at org.hibernate.engine.spi.ActionQueue.addAction(ActionQueue.java:322)
at org.hibernate.event.internal.AbstractSaveEventListener.addInsertAction(AbstractSaveEventListener.java:363)
at org.hibernate.event.internal.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:277)
at org.hibernate.event.internal.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:180)
at org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:140)
at org.hibernate.event.internal.DefaultPersistEventListener.entityIsTransient(DefaultPersistEventListener.java:175)
at org.hibernate.event.internal.DefaultPersistEventListener.persist(DefaultPersistEventListener.java:93)
at org.hibernate.event.internal.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:77)
at org.hibernate.event.internal.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:54)
at org.hibernate.event.service.internal.EventListenerGroupImpl.fireEventOnEachListener(EventListenerGroupImpl.java:127)
at org.hibernate.internal.SessionImpl.firePersist(SessionImpl.java:755)
at org.hibernate.internal.SessionImpl.persist(SessionImpl.java:739)
at io.quarkus.hibernate.orm.runtime.session.TransactionScopedSession.persist(TransactionScopedSession.java:145)
at org.hibernate.engine.spi.SessionLazyDelegator.persist(SessionLazyDelegator.java:275)
at org.hibernate.Session_3a974b6a18ac399f675913d732c105426414d370_Synthetic_ClientProxy.persist(Unknown Source)
at io.quarkus.hibernate.orm.panache.common.runtime.AbstractJpaOperations.persist(AbstractJpaOperations.java:101)
at io.quarkus.hibernate.orm.panache.common.runtime.AbstractJpaOperations.persist(AbstractJpaOperations.java:96)
at io.quarkus.hibernate.orm.panache.kotlin.PanacheRepositoryBase$DefaultImpls.persist(PanacheRepositoryBase.kt:36)
at io.quarkus.hibernate.orm.panache.kotlin.PanacheRepository$DefaultImpls.persist(PanacheRepository.kt:11)
at com.faforever.userservice.backend.domain.LoginLogRepository.persist(LoginLog.kt:39)
at com.faforever.userservice.backend.domain.LoginLogRepository.persist(LoginLog.kt:39)
at com.faforever.userservice.backend.domain.LoginLogRepository_ClientProxy.persist(Unknown Source)
at com.faforever.userservice.backend.domain.LoginServiceImpl.logFailedLogin-CqDmdvU(LoginService.kt:104)
at com.faforever.userservice.backend.domain.LoginServiceImpl.login-WjPDJGo(LoginService.kt:75)
at com.faforever.userservice.backend.domain.LoginServiceImpl_ClientProxy.login-WjPDJGo(Unknown Source)
at com.faforever.userservice.backend.hydra.HydraService.login-sOsN0x8(HydraService.kt:66)
at com.faforever.userservice.backend.hydra.HydraService_Subclass.login-sOsN0x8$$superforward(Unknown Source)
at com.faforever.userservice.backend.hydra.HydraService_Subclass$$function$$1.apply(Unknown Source)

Maybe it fails because Unicode is not allowed in the login_log table?

@Brutus5000 Brutus5000 added the good first issue Good for newcomers label Oct 5, 2023
@fcaps
Copy link
Contributor

fcaps commented Nov 6, 2023

Since i could not reproduce it on the local stack right away, i changed the collation in the table to "latin1_general_ci" and got a similar error. Update the collation to "utf8mb4_general_ci" should fix this.

ALTER TABLE login_log CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

Another possibility is to remove the login_string completely if the user was not found. I cannot think of another use than "Hey i cannot login -> yeah, you typed your username wrong" scenario where this info could be useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants