java - Fixed fortify scan Locale changes are reappearing -
i have 1 j2ee application , application, fortify scan shows locale dependent issues.
i have fixed issues using locale.english in touppercase(locale.english) , tolowercase(locale.english) functions while comparing strings, earlier,
firstname.trim().tolowercase();
now
firstname.trim().tolowercase(locale.english);
and again run fortify scan on application. however, second time, fortify scan shows locale error @ same place.
does knows, how can fix these kind of issues?
thanks, jay
the issue category "portability flaw: locale dependent comparison" (ruleguid=d8e9ed3b-22ec-4cba-98c8-7c67f73ccf4c) belongs "code quality" kingdom , low risk issue. leave un-remediated.
rationale when "java.lang.string.touppercase()/tolowercase()" used without setting locale, use default locale. may cause security checking being bypassed. example, want exclude "script" user input; if default language turkish, tag.touppercase() returns "t\u0130tle", "\u0130" "latin capital letter dot above" character. therefor "script" checking bypassed.
if (tag.touppercase().equals("script")){ return null;}
remediation
(1) can set language when start vm, , mark issue "not issue"
java -duser.language=en -duser.country=us -duser.variant=us mainclass
(2) or, set language code
import java.util.locale; //be aware locale.setdefault global, below set locale en_us_win locale.setdefault(new locale("en", "us", "win"));
(3) or, if clients use different languages, use httpservletrequest.getlocale
// see sample code here
Comments
Post a Comment