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

Missing Type Juggling Vulnerability Checks in ASVS #1539

Closed
ImanSharaf opened this issue Feb 7, 2023 · 15 comments
Closed

Missing Type Juggling Vulnerability Checks in ASVS #1539

ImanSharaf opened this issue Feb 7, 2023 · 15 comments
Labels
4a) Waiting for another This issue is waiting for another issue to be resolved V10 tmp code-review Temporary label for grouping code review or program code related issues _5.0 - prep This needs to be addressed to prepare 5.0

Comments

@ImanSharaf
Copy link
Collaborator

It appears that type juggling checks are not currently in place, which could potentially leave some systems open to attacks.

Type juggling is a common vulnerability that occurs when type conversions are not properly validated. This can lead to unintended behavior, such as security weaknesses, that can be exploited by malicious actors.

I strongly recommend that you take this issue into consideration and implement the necessary checks to prevent type juggling vulnerabilities.

Thank you for your time and efforts in maintaining ASVS.

@elarlang
Copy link
Collaborator

elarlang commented Feb 8, 2023

I would say we don't have clearly suitable category for the requirement.

@ImanSharaf
Copy link
Collaborator Author

@elarlang What about category 5?

@elarlang elarlang added the V10 tmp code-review Temporary label for grouping code review or program code related issues label Mar 10, 2023
@tghosth
Copy link
Collaborator

tghosth commented Mar 14, 2023

Sounds like input validation (section 5.1).

How about:

Verify that strong variable comparisons are performed to avoid type juggling vulnerabilities.

What do you think @ImanSharaf @elarlang ?

@tghosth tghosth added 2) Awaiting response Awaiting a response from the original poster _5.0 - prep This needs to be addressed to prepare 5.0 labels Mar 14, 2023
@elarlang
Copy link
Collaborator

elarlang commented Mar 14, 2023

It's not only validating user-input.

For example, in PHP world it may happen everywhere in the code if you don't check type.
https://www.php.net/manual/en/language.types.type-juggling.php

edit: Requirement text is ok, but we don't have suitable category for that at the moment. I labeled it to "code review" to group similar requirements together and maybe we need to create new (sub)category for those.

@ImanSharaf
Copy link
Collaborator Author

Thank you for considering my suggestion. @tghosth The requirement text you proposed, "Verify that strong variable comparisons are performed to avoid type juggling vulnerabilities," captures the essence of the issue well. @elarlang I understand your concern about type juggling occurring not just in user input validation but also in other parts of the code. However, it is important to note that if the type juggling is not a result of user input or externally influenced data, the potential security risk would be significantly lower, as it would not be directly exploitable by malicious actors.

@elarlang
Copy link
Collaborator

However, it is important to note that if the type juggling is not a result of user input or externally influenced data, the potential security risk would be significantly lower, as it would not be directly exploitable by malicious actors.

As boolean true fact we can apply this logic everywhere, but we don't do it. Based on HTML injection (XSS): do we say, that if users don't control the data directly, then we don't need to encode it for the output? We don't say that. Display layer need to work without knowing from where the data comes. Program code need to work without making difference, does it handles user input or data from any other source. Otherwise, if something is reorganized, like some part of program code now handles userinput, no one have overview of it.

@tghosth
Copy link
Collaborator

tghosth commented Mar 21, 2023

@elarlang how about a section called "Secure Input handling" I think that would cover all the tmp code-review examples. What do you think?

@elarlang
Copy link
Collaborator

elarlang commented Apr 5, 2023

@elarlang how about a section called "Secure Input handling" I think that would cover all the tmp code-review examples. What do you think?

The title itself without context (for me) does not say what it is (I can say "Secure Input Handling" for output encoding and escaping as well). In general - if we can make it clear and separate from other categories (with clear scope), then we can create it. Maybe 5.4 or 5.5 needs renaming for that? (probably worth separate issue)

@tghosth
Copy link
Collaborator

tghosth commented May 31, 2023

@elarlang I think we are going to naturally discover that we need to create a new section to hold a bunch of attack specific protections. At this point, I don't see any way around that.... We will see this as we work on the V5 issues.

In the meantime, do we have any thing to add other than the following?

Verify that strong variable comparisons are performed to avoid type juggling vulnerabilities.

@elarlang
Copy link
Collaborator

For category it waits: #1643

@tghosth
Copy link
Collaborator

tghosth commented Jun 15, 2023

What do you think about the input validation section for this one? To my mind, this is an input validation mechanism but they need to be performing the validation securely.

@elarlang
Copy link
Collaborator

I don't think it's an input validation problem. Let's say user enters value 0 in HTML input field and HTTP protocol does not define what is the type for that. Validation - should an application accept the input or not.

It's up to the program code to use the value correctly. Given example in PHP may cause interpretation as "false":

if ($_POST['text-field-name']) { ... }

@tghosth
Copy link
Collaborator

tghosth commented Jul 9, 2023

Ok so can you think of any other way of categorising it?

@tghosth
Copy link
Collaborator

tghosth commented Jul 10, 2023

Suggested a fix in #1617 (comment) to address this along with type confusion.

@tghosth tghosth added 4a) Waiting for another This issue is waiting for another issue to be resolved and removed 2) Awaiting response Awaiting a response from the original poster labels Sep 21, 2023
@tghosth
Copy link
Collaborator

tghosth commented Sep 26, 2023

I am going to close this as I don't think there is any separate action on top of #1617

@tghosth tghosth closed this as completed Sep 26, 2023
@tghosth tghosth closed this as not planned Won't fix, can't repro, duplicate, stale Sep 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4a) Waiting for another This issue is waiting for another issue to be resolved V10 tmp code-review Temporary label for grouping code review or program code related issues _5.0 - prep This needs to be addressed to prepare 5.0
Projects
None yet
Development

No branches or pull requests

3 participants