@@ -274,8 +274,12 @@ public function displayReport(&$result, $Addressing, $values, $ping_status = [])
274274 foreach ($ lines as $ line ) {
275275 $ row_num ++;
276276 $ item_num = 1 ;
277- $ name = $ line ["dname " ];
278- $ namep = $ line ["pname " ];
277+ // Asset/port names are stored raw in DB and rendered through the
278+ // legacy HTMLSearchOutput::showItem(), which emits its value verbatim.
279+ // Escape here so a hostile asset/port name cannot inject markup into
280+ // the report (stored XSS across the entity/right boundary).
281+ $ name = htmlspecialchars ((string ) $ line ["dname " ], ENT_QUOTES , 'UTF-8 ' );
282+ $ namep = htmlspecialchars ((string ) $ line ["pname " ], ENT_QUOTES , 'UTF-8 ' );
279283 // IP
280284 if ($ is_html_output ) {
281285 if ($ Addressing ->fields ["reserved_ip " ] && strstr (
@@ -359,6 +363,7 @@ public function displayReport(&$result, $Addressing, $values, $ping_status = [])
359363 $ user ->fields ["firstname " ]
360364 );
361365
366+ $ username = htmlspecialchars ((string ) $ username , ENT_QUOTES , 'UTF-8 ' );
362367 if ($ user ->canView ()) {
363368 $ output_iduser = "<a href=' " . $ CFG_GLPI ["root_doc " ] . "/front/user.form.php?id= "
364369 . $ line ["users_id " ] . "'> " . $ username . "</a> " ;
@@ -380,11 +385,12 @@ public function displayReport(&$result, $Addressing, $values, $ping_status = [])
380385
381386 // Mac
382387 if ($ line ["id " ]) {
388+ $ mac = htmlspecialchars ((string ) $ line ["mac " ], ENT_QUOTES , 'UTF-8 ' );
383389 if ($ item ->canView ()) {
384390 $ output_mac = "<a href=' " . $ CFG_GLPI ["root_doc " ] . "/front/networkport.form.php?id= "
385- . $ line ["id " ] . "'> " . $ line [ " mac " ] . "</a> " ;
391+ . $ line ["id " ] . "'> " . $ mac . "</a> " ;
386392 } else {
387- $ output_mac = $ line [ " mac " ] ;
393+ $ output_mac = $ mac ;
388394 }
389395 if ($ is_html_output ) {
390396 $ html_output .= $ output ::showItem ($ output_mac , $ item_num , $ row_num );
@@ -1011,7 +1017,7 @@ function updateFA$rand() {
10111017 if ($ is_html_output ) {
10121018 $ html_output .= $ output ::showItem (
10131019 '<input type="text" id="comment ' . $ num . '"
1014- value=" ' . $ comments . '"> ' ,
1020+ value=" ' . htmlspecialchars ( $ comments, ENT_QUOTES , ' UTF-8 ' ) . '"> ' ,
10151021 $ item_num ,
10161022 $ row_num ,
10171023 "style='background-color:#e0e0e0' class='center' onChange='updateFA $ rand()' "
0 commit comments