Skip to content

Commit 5cbc72c

Browse files
eldythomas-Ngr
authored andcommitted
Sec: sql injection via api in POST of thirdparties/id/banckaccount -
reported by MDnyn
1 parent 3ccd29a commit 5cbc72c

6 files changed

Lines changed: 8 additions & 8 deletions

File tree

htdocs/accountancy/admin/productaccount.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@
352352
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.account_number = p." . $db->sanitize($accountancy_field_name) . " AND aa.fk_pcg_version = '" . $db->escape($pcgvercode) . "'";
353353
}
354354
if (!empty($searchCategoryProductList)) {
355-
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_product as cp ON p.rowid = cp.fk_product"; // We'll need this table joined to the select in order to filter by categ
355+
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON p.rowid = cp.fk_product"; // We'll need this table joined to the select in order to filter by categ
356356
}
357357
$sql .= ' WHERE p.entity IN ('.getEntity('product').')';
358358
if (strlen(trim($search_current_account))) {

htdocs/adherents/class/subscription.class.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -518,9 +518,9 @@ public function LibStatut($status, $mode = 0)
518518
*/
519519
public function info($id)
520520
{
521-
$sql = 'SELECT c.rowid, c.datec, c.tms as datem, c.fk_user_creat';
522-
$sql .= ' FROM '.MAIN_DB_PREFIX.'subscription as c';
523-
$sql .= ' WHERE c.rowid = '.((int) $id);
521+
$sql = "SELECT c.rowid, c.datec, c.tms as datem, c.fk_user_creat";
522+
$sql .= " FROM ".MAIN_DB_PREFIX."subscription as c";
523+
$sql .= " WHERE c.rowid = ".((int) $id);
524524

525525
$resql = $this->db->query($sql);
526526
if ($resql) {

htdocs/admin/external_rss.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@
148148
$obj = $db->fetch_object($resql);
149149

150150
$sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes";
151-
$sql .= " WHERE entity = ".$conf->entity;
151+
$sql .= " WHERE entity = ".((int) $conf->entity);
152152
$sql .= " AND box_id = ".((int) $obj->rowid);
153153
$resql = $db->query($sql);
154154

htdocs/contrat/class/contratligne.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -839,7 +839,7 @@ public function insert($notrigger = 0)
839839
if ($this->date_end > 0) {
840840
$sql .= ",date_fin_validite";
841841
}
842-
$sql .= ") VALUES ($this->fk_contrat, '', '".$this->db->escape($this->description)."',";
842+
$sql .= ") VALUES (".((int) $this->fk_contrat).", '', '".$this->db->escape($this->description)."',";
843843
$sql .= ($this->fk_product > 0 ? $this->fk_product : "null").",";
844844
$sql .= " '".$this->db->escape((string) $this->qty)."',";
845845
$sql .= " '".$this->db->escape($this->vat_src_code)."',";

htdocs/core/class/discount.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ public function create($user)
349349
$sql .= " multicurrency_amount_ht, multicurrency_amount_tva, multicurrency_amount_ttc,";
350350
$sql .= " fk_facture_source, fk_invoice_supplier_source, multicurrency_code, multicurrency_tx";
351351
$sql .= ")";
352-
$sql .= " VALUES (".$conf->entity.", '".$this->db->idate($this->datec != '' ? $this->datec : dol_now())."', ".((int) $this->socid).", ".(empty($this->discount_type) ? 0 : intval($this->discount_type)).", ".((int) $userid).", '".$this->db->escape($this->description)."',";
352+
$sql .= " VALUES (".((int) $conf->entity).", '".$this->db->idate($this->datec != '' ? $this->datec : dol_now())."', ".((int) $this->socid).", ".(empty($this->discount_type) ? 0 : intval($this->discount_type)).", ".((int) $userid).", '".$this->db->escape($this->description)."',";
353353
$sql .= " ".price2num($this->amount_ht).", ".price2num($this->amount_tva).", ".price2num($this->amount_ttc).", ".price2num($this->tva_tx).", '".$this->db->escape($this->vat_src_code)."',";
354354
$sql .= " ".price2num($this->multicurrency_amount_ht).", ".price2num($this->multicurrency_amount_tva).", ".price2num($this->multicurrency_amount_ttc).", ";
355355
$sql .= " ".($this->fk_facture_source ? ((int) $this->fk_facture_source) : "null").",";

htdocs/user/class/userbankaccount.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public function create($user, $notrigger = 0)
9696
$now = dol_now();
9797

9898
$sql = "INSERT INTO ".$this->db->prefix()."user_rib (fk_user, datec)";
99-
$sql .= " VALUES (".$this->userid.", '".$this->db->idate($now)."')";
99+
$sql .= " VALUES (".((int) $this->userid).", '".$this->db->idate($now)."')";
100100
$resql = $this->db->query($sql);
101101
if ($resql) {
102102
if ($this->db->affected_rows($resql)) {

0 commit comments

Comments
 (0)