The encrypt key is logged out in sql statement - when included in where predicate
I'm using the default @Encrypted to encrypt password field , but output log will display my encrypt key
select t0.id from user t0 where CONVERT(AES_DECRYPT(t0.password,?) USING UTF8) = ? ; --bind(MY_ENCRYPT_KEY)
can Ebean provide a configuration to disable encrypt key logged out ?
Thanks!
Can you give a code example with the bind value.
The encrypt key should not be logged ... there are 2 ? bind values in the example above and only one of those is logged (and it should not be the encrypt key). So it is not exactly clear to me yet you have a valid issue. Can you give a full code example and full log message.
Thanks.
On 24 November 2015 at 15:36, EChrist [email protected] wrote:
I'm using the default @Encrypted to encrypt password field , but output log will display my encrypt key
select t0.id from user t0 where CONVERT(AES_DECRYPT(t0.password,?) USING UTF8) = ? ; --bind(MY_ENCRYPT_KEY)
can Ebean provide a configuration to disable encrypt key logged out ?
Thanks!
— Reply to this email directly or view it on GitHub https://github.com/ebean-orm/avaje-ebeanorm/issues/465.
Sorry my fault , the full log is
TRACE org.avaje.ebean.SQL - txn[s6982402] select t0.id c0, t0.creator_system c1, t0.modifier_system c2, t0.creator c3, t0.modifier c4, t0.is_delete c5, t0.type c6, t0.login_name c7, t0.mobile c8, t0.email c9, t0.remark c10, t0.status c11, t0.createtime c12, t0.modifytime c13 from user t0 where t0.is_delete = ? and t0.mobile = ? and CONVERT(AES_DECRYPT(t0.password,?) USING UTF8) = ? and t0.type = ? ; --bind(0,12345678901,MY_ENCRYPT_KEY,a,CLIENT)
and the encrypt key is MY_ENCRYPT_KEY
And you are going to include the java code that executes the query ... including the bind values being set?
On 24 November 2015 at 16:32, EChrist [email protected] wrote:
Sorry my fault , the full log is
TRACE org.avaje.ebean.SQL - txn[s6982402] select t0.id c0, t0.creator_system c1, t0.modifier_system c2, t0.creator c3, t0.modifier c4, t0.is_delete c5, t0.type c6, t0.login_name c7, t0.mobile c8, t0.email c9, t0.remark c10, t0.status c11, t0.createtime c12, t0.modifytime c13 from user t0 where t0.is_delete = ? and t0.mobile = ? and CONVERT(AES_DECRYPT(t0.password,?) USING UTF8) = ? and t0.type = ? ; --bind(0,12345678901,MY_ENCRYPT_KEY,a,CLIENT)
and the encrypt key is MY_ENCRYPT_KEY
— Reply to this email directly or view it on GitHub https://github.com/ebean-orm/avaje-ebeanorm/issues/465#issuecomment-159141200 .
The query is
User user = Ebean.find(User.class)
.where()
.eq("isDelete",0)
.eq("mobile", "12345678901")
.eq("password", "a")
.eq("type", "CLIENT")
.findUnique();
The User.java is like
@Entity
public class User{
@Encrypted
@Lob
private String password;
...
}
and the EncryptKeyManager
public class SystemEncryptKeyManager implements EncryptKeyManager {
@Override
public void initialise() {
//empty here
}
@Override
public EncryptKey getEncryptKey(String tableName, String columnName) {
return new EncryptKey() {
@Override
public String getStringValue() {
return "MY_ENCRYPT_KEY";
}
};
}
}
may be the --bind(0,12345678901,MY_ENCRYPT_KEY,a,CLIENT) in log replaced with --bind(0,12345678901,***,a,CLIENT) is what I expected . or just --bind(0,12345678901,a,CLIENT)
remove the MY_ENCRYPT_KEY
Thanks.
Hmmm, did not reproduce initially:
23:44:14.872 [main] DEBUG org.avaje.ebean.SQL - txn[1005] select t0.id c0, t0.name c1, TRIM(CHAR(0) FROM UTF8TOSTRING(DECRYPT('AES', STRINGTOUTF8(?), t0.description))) c2, PARSEDATETIME(TRIM(CHAR(0) FROM UTF8TOSTRING(DECRYPT('AES', STRINGTOUTF8(?), t0.dob))),'yyyyMMdd') c3, t0.last_update c4 from e_basicenc t0 where TRIM(CHAR(0) FROM UTF8TOSTRING(DECRYPT('AES', STRINGTOUTF8(?), t0.description))) like ? and PARSEDATETIME(TRIM(CHAR(0) FROM UTF8TOSTRING(DECRYPT('AES', STRINGTOUTF8(?), t0.dob))),'yyyyMMdd') >= ?; --bind(****, testde%, ****, 2015-11-25, )
23:44:14.874 [main] DEBUG org.avaje.ebean.SUM - txn[1005] FindMany type[EBasicEncrypt] origin[ddSis.DkQKjz.BvQ020] exeMicros[3806] rows[1] name[] predicates[TRIM(CHAR(0) FROM UTF8TOSTRING(DECRYPT('AES', STRINGTOUTF8(?), t0.description))) like ? and PARSEDATETIME(TRIM(CHAR(0) FROM UTF8TOSTRING(DECRYPT('AES', STRINGTOUTF8(?), t0.dob))),'yyyyMMdd') >= ?] bind[****, testde%, ****, 2015-11-25, ]
Note the **** in the bind section of the log. Hmmm.
Ah ok, I think I have reproduced.