Adding HINFO record breaks DNS

Discussion in 'General' started by NdK, Apr 11, 2025.

  1. NdK

    NdK Member

    Hello.

    I just noticed that adding a HINFO record generates a damaged line like
    swt-mgmt8021x 3600 HINFO HP 2530-48G Switch (J9775A)" "Aruba
    (note the missing quotes at start and end).
    After that, the zone won't take any more changes (they end up in .err zone file and the last working version is restored).

    I think it's due to some recent change in ISPConfig, since I have old HINFO records that got added correctly.
    I'm using ISPConfig 3.2.12p1
     
  2. pyte

    pyte Well-Known Member HowtoForge Supporter

    I don't think spaces are allowed in HINFO RRs.

    As the entry does not match any standard HINFO RR, do you use these for internal use only? This record would not be recognized by anyone else as it not follows standards
     
  3. till

    till Super Moderator Staff Member ISPConfig Developer

    Besides that, I don't think we changed anything recently regarding HINFO.
     
  4. NdK

    NdK Member

    The correct record should be
    swt-mgmt8021x 3600 HINFO "HP 2530-48G Switch (J9775A)" "Aruba"
    with starting and ending quotes. IIUC it's like a TXT record but containing two space-separated fields (HW and SW), that have to be enclosed in quotes if they contain spaces.
    Maybe the change is something more general (like stripping quotes from records). I can't easily pinpoint a version 'cause I rarely add HINFO records (last addition was about 2y ago, IIRC... maybe more).
     
  5. pyte

    pyte Well-Known Member HowtoForge Supporter

    Well this works just fine for me:
    upload_2025-4-14_11-54-43.png


    ;; ANSWER SECTION:
    swt-mgmt8021x.testdomain.de. 3555 IN HINFO "HP 2530-48G Switch (J9775A)" "Aruba"
     
  6. NdK

    NdK Member

    Just tested again.
    If I copy-paste from my post (including quotes) to the form, quotes gets stripped.
    BUT if I include a leading space before pasting, quotes are preserved and it seems to work.
     
  7. pyte

    pyte Well-Known Member HowtoForge Supporter

    I don't know what you are doing. I just copy pasted it from your post earlier and it worked just fine. As till already mentioned there seem to be no changes to the hinfo related files in ISPConfig - so it should behave as i always did and for me it does.

    May try typing it in manually and see if it is some weird copy/past issue.
     
  8. NdK

    NdK Member

    Nope. Tried changing browser: same error.
    Edited an existing record: idem.

    Ran ispconfig_update.sh --force (to refresh all the files): no change
    Now I'm looking at the code. The first thing that I found is that the validator in /usr/local/ispconfig/interface/lib/classes/validate_dns.inc.php could be improved (yes, I'm volunteering, if till is OK with it and it's actually used -- couldn't find anything calling validate_rr() ... maybe it's a future evolution?): currently it only checks that the record contains a space, not that it's actually two entities...
    But trying other paths, I noticed that if I manually escape the "external" quotes I get an interesting message in ispconfig.log:
    data = 'HP_2530-48G_Switch_(J9775A\" \"Aruba\\\"
    The first pair of quotes is gone, the last one is still there, with extra escaping... Maybe a DB or PHP setting?
     
  9. NdK

    NdK Member

    FOUND THE BUG!
    /usr/local/ispconfig/interface/web/dns/dns_edit_base.php lines 132-136. It does not consider that for some records the quotes are actually needed, at least sometimes.
    Sure, in my case I could just have dropped the quotes around Aruba (no spaces => quotes not needed) but that's a workaround and it's not always applicable. The other one (adding a space before the record) would have worked till a "cleanup" that removed spaces.
    PS: it's a "recent" change, as long as "in the last year" can be considered recent. The backups taken on 2024-04-12 and on 2024-08-01 do not contain that code.
     
    Last edited: Apr 15, 2025
  10. pyte

    pyte Well-Known Member HowtoForge Supporter

    Great news thanks for checking! Seems like this commit caused the issue:
    https://git.ispconfig.org/ispconfig/ispconfig3/-/commit/93680219dd95921498fdd373831cfaaba38ced83

    I did not affect my version because this patch is currently not applied on the system i tested this on. Sorry!

    Seem like the regex /^"(.*)"$/ matches your data entry which then removes the outer quotes and leaves you with

    HP 2530-48G Switch (J9775A)" "Aruba

    instead of

    "HP 2530-48G Switch (J9775A)" "Aruba"

    Which then caused the issue. I guess we should fix this with correct validators instead of removing the quotes altogether or at least show some info when using quotes in the data field.
     
    NdK and till like this.
  11. till

    till Super Moderator Staff Member ISPConfig Developer

    I'll change the code to:

    Code:
    $matches = array();
            if(substr_count($this->dataRecord["data"], '"') == 2 && preg_match('/^"(.*)"$/', $this->dataRecord["data"], $matches)) {
                $this->dataRecord["data"] = $matches[1];
            }
    So we only remove double-quotes if no double-quotes are inside.
     
    remkoh and pyte like this.
  12. NdK

    NdK Member

    Good for a temporary fix, waiting for record-specific validators. But probably a regexp of
    '^"([^"]*"$'
    is faster and should give the same result: the string starts with quotes, contains any character except quotes and ends with quotes, no need for extra substr_count call.

    BTW this could create problems to other records too: according to RFC1035
     
    Last edited: Apr 15, 2025
  13. pyte

    pyte Well-Known Member HowtoForge Supporter

    Well usually HINFO RRs do not use spaces anywhere so that is that. Anyways i guess the best solution for this would be a seperate form for HINFO record like we do for DMARC/SPF for example, where the user can only set the CPU and OS field, strip all quotes from the fields and wrap them in double quotes afterwards.

    That is quiet a bit more work but i think we can't find a one size fits all solution here for all possible RR Types.
     
  14. NdK

    NdK Member

    That would be the best solution. But I don't know ISPConfig internals well enough to implement it :(
    That doesn't mean I won't try anyway... :)
     

Share This Page