Skip to content

Commit bd15cbe

Browse files
author
wrongecho
committed
- Stripe saved cards - lock down invoice and client IDs
- Stop app log handling from breaking due to quotes
1 parent c5d67cd commit bd15cbe

2 files changed

Lines changed: 12 additions & 10 deletions

File tree

client/post.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -524,12 +524,6 @@
524524
$contact_extension = preg_replace("/[^0-9]/", '',$row['contact_extension']);
525525
$contact_mobile = sanitizeInput(formatPhoneNumber($row['contact_mobile'], $row['contact_mobile_country_code']));
526526

527-
// Check to make sure saved payment method belongs to logged in client
528-
if ($client_id !== $session_client_id) {
529-
flash_alert("Saved Payment method does not belong to you!", 'danger');
530-
redirect();
531-
}
532-
533527
// Get ITFlow company details
534528
$sql = mysqli_query($mysqli,"SELECT * FROM companies WHERE company_id = 1");
535529
$row = mysqli_fetch_assoc($sql);
@@ -548,7 +542,7 @@
548542
$config_invoice_from_email = sanitizeInput($config_invoice_from_email);
549543

550544
// Get Client Payment Details
551-
$sql = mysqli_query($mysqli, "SELECT * FROM client_saved_payment_methods LEFT JOIN payment_providers ON saved_payment_provider_id = payment_provider_id LEFT JOIN client_payment_provider ON saved_payment_client_id = client_id WHERE saved_payment_id = $saved_payment_id LIMIT 1");
545+
$sql = mysqli_query($mysqli, "SELECT * FROM client_saved_payment_methods LEFT JOIN payment_providers ON saved_payment_provider_id = payment_provider_id LEFT JOIN client_payment_provider ON saved_payment_client_id = client_id WHERE saved_payment_id = $saved_payment_id AND saved_payment_client_id = $session_client_id LIMIT 1");
552546
$row = mysqli_fetch_assoc($sql);
553547

554548
$public_key = sanitizeInput($row['payment_provider_public_key']);
@@ -561,9 +555,17 @@
561555
$payment_provider_client = sanitizeInput($row['payment_provider_client']);
562556
$saved_payment_method = sanitizeInput($row['saved_payment_provider_method']);
563557
$saved_payment_description = sanitizeInput($row['saved_payment_description']);
558+
$payment_client_id = intval($row['saved_payment_client_id']);
564559

565560
// Sanity checks
566-
if (!$payment_provider_client || !$saved_payment_method) {
561+
// Check to make invoice belongs to logged in client
562+
if ($client_id !== $session_client_id) {
563+
flash_alert("Invoice does not belong to you!", 'danger');
564+
redirect();
565+
} elseif ($payment_client_id !== $session_client_id) {
566+
flash_alert("Saved Payment method does not belong to you!", 'danger');
567+
redirect();
568+
} elseif (!$payment_provider_client || !$saved_payment_method) {
567569
flash_alert("Stripe not enabled or no client card saved", 'error');
568570
redirect();
569571
} elseif ($invoice_status !== 'Sent' && $invoice_status !== 'Viewed') {

functions.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1512,8 +1512,8 @@ function logAction($type, $action, $description, $client_id = 0, $entity_id = 0)
15121512
function logApp($category, $type, $details) {
15131513
global $mysqli;
15141514

1515-
$category = substr($category, 0, 200);
1516-
$details = substr($details, 0, 1000);
1515+
$category = mysqli_real_escape_string($mysqli, substr($category, 0, 200));
1516+
$details = mysqli_real_escape_string($mysqli, substr($details, 0, 1000));
15171517

15181518
mysqli_query($mysqli, "INSERT INTO app_logs SET app_log_category = '$category', app_log_type = '$type', app_log_details = '$details'");
15191519
}

0 commit comments

Comments
 (0)