Skip to main content

Inappropriate coding practices - Public variables


The code presents several classes whose variables are declared as public.


  • Get or set a public variable by any part of the program, and any rules regarding its use can be easily broken or forgotten.
  • Exploit the use of public variables in the code by accessing them through classes external to the application in order to modify the values of these variables and compromise the integrity of the application.


Unless strictly necessary, all variables should be declared as private.


Unauthorized attacker with access to the application.

Expected Remediation Time

⌚ 15 minutes.


Default score using CVSS 3.1. It may change depending on the context of the vulnerability.


  • Attack vector: L
  • Attack complexity: L
  • Privileges required: N
  • User interaction: N
  • Scope: U
  • Confidentiality: N
  • Integrity: L
  • Availability: N


  • Exploit code madurity: P
  • Remediation level: O
  • Report confidence: X


  • Vector string: CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:N/E:P/RL:O/RC:X
  • Score:
    • Base: 4.0
    • Temporal: 3.6
  • Severity:
    • Base: Medium
    • Temporal: Low

Code Examples

Compliant code

The application does not use static variable declaration

public class UserExample {
private user_key a;
private user_id b;

Non compliant code

The application uses static variable declaration when not strictly necessary

public class UserExample {
public static user_key a;
public static user_id b;


free trial

Search for vulnerabilities in your apps for free with our automated security testing! Start your 21-day free trial and discover the benefits of our Continuous Hacking Machine Plan. If you prefer a full service that includes the expertise of our ethical hackers, don't hesitate to contact us for our Continuous Hacking Squad Plan.