Unexpected variable reset

1.61K viewsJava Card

Unexpected variable reset

BACKGROUND:

I’m working with NXP JCOP4 based cards on a custom applet.

At two separate instances I faced that value of a certain variable got reset (I can tell the exact value for only instance and that was 0; I’m assuming that same happened in the second time as well).

This was not at all expected because the variable assignment is done at only one place in the entire source code. Additionally, this part of code becomes inaccessible once the value of this variable changes (and I could confirm that the value actually changed as expected). So I believe it is not a logical bug (otherwise it would occur more often).

The applet on which I’m working is a bit large occupying 17kb of space (on physical cards) for source code and around 10kb of additional memory for installation. In both instances the variables has a scope of “public static” and I was suggested to not use static unless necessary, so I made the change. But I could not recreate the issue in any of multiple attempts to do so.

QUESTION:

Has anyone experienced this type of behaviour on Javacard? Or any mitigation techniques that someone might know.

JIJO THOMAS Answered question December 8, 2021
0

I am not sure when exactly it is happening but hopefully something with CLEAR_ON_DESELECT and CLEAR_ON_RESET. Please check this first

cyph Posted new comment December 8, 2021

Actually those variables were on NVM so DESELECT/RESET should not affect them at any point.

Yes I understand it is difficult to guess the cause without looking at the implementation.

0
You are viewing 1 out of 1 answers, click here to view all answers.