Bug 16520

Summary: layerindex: a NUL byte in a search or URL gives 500 on PostgreSQL
Product: [Yocto Project Subprojects] Layer Index Reporter: Tim Orling <tim.orling>
Component: Layer IndexAssignee: Tim Orling <tim.orling>
Status: NEW --- QA Contact: apoorv sangal <apoorvsangal>
Severity: normal    
Priority: Medium    
Version: 6.1   
Target Milestone: 6.2   
Hardware: All   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: No (bug/feature does not impact docs)

Description Tim Orling 2026-11-16 04:19:33 UTC
PostgreSQL text can't hold a NUL byte, so a query that compares a column with a string containing one raises DataError and gives a 500:

    /layerindex/branch/master/recipes/?q=%00
    /layerindex/api/recipes/?filter=pn:%00
    /rrs/recipes/%00/6.2/M1/
    DataError: PostgreSQL text fields cannot contain NUL (0x00) bytes

MariaDB accepts these and returns no results. This needs fixing before the move to PostgreSQL (bug 16476): reject or strip NUL in search terms and path values before they reach the database (e.g. Django's ProhibitNullCharactersValidator on the search forms, or one middleware returning 400). Found by fuzz testing a bench instance running PostgreSQL 17.