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

Handle invalid entityids when favorting Questions or Users #921

Open
q2apro opened this issue Nov 5, 2021 · 0 comments
Open

Handle invalid entityids when favorting Questions or Users #921

q2apro opened this issue Nov 5, 2021 · 0 comments

Comments

@q2apro
Copy link

q2apro commented Nov 5, 2021

In \qa-include\ajax\favorite.php the incoming values are not validated.

$entitytype = qa_post_text('entitytype');
$entityid = qa_post_text('entityid');
$setfavorite = qa_post_text('favorite');

It should be probably be validated like this:

$entitytype = qa_post_text('entitytype'); // Q, U, T, C
$entityid = qa_post_text('entityid'); // bigint, e.g. 123456
$setfavorite = (int)qa_post_text('favorite'); // 0 or 1, so cast to int

// validate data
$entitytypes = ['Q', 'U', 'T', 'C'];
if(!in_array($entitytype, $entitytypes))
{
	echo "QA_AJAX_RESPONSE\n0\n" . "Wrong entity type";
}

$entityid = preg_replace('/[^0-9]/', '', $entityid);
// or checking with ctype_digit($blobid)

Similar to #919

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant