Skip to content
This repository was archived by the owner on Mar 10, 2026. It is now read-only.
This repository was archived by the owner on Mar 10, 2026. It is now read-only.

squash non-UTF-8 strings into ASCII on plain IPP level #5186

Closed

Description

@vliaskov

Currently if users submit jobs with non UTF-8 strings, these invalid strings will be detected in
ippValidateAttribute, and the job will be rejected.

Specifically for a non-UTF-8 requesting-user-name this happens with commit 49fa498

The scenario of users submitting jobs with a non-UTF-8 requesting-user-name has been observed in production systems. These users would not want their jobs to be rejected obviously.

Is it possible to implement squashing / conversion of such non-UTF-8 strings into ASCII? This way jobs
with such string can proceed. E.g. when cupsd receives a sequence of bytes that are not UTF-8, all non-ASCII bytes (i.e. all bytes with highest bit set) can be converted (actually "squashed") into an ASCII byte.

Such "squashing non-UTF-8 into ASCII" should probably not be done for all IPP values cupsd receives. For example print queue names and default print job option values that are non-UTF-8 should not be changed, because than cupsd would be guessing valid print queue names and options.

I think that in scheduler/ipp.c ippValidateAttribute() calls and job rejection on invalid string detection happen currently only for:

requesting-user-name
job-name

So for these IPP values and perhaps others that are only informative (i.e. where the actual value does not really matter for processing the print job) cupsd could squash non-UTF-8 into ASCII?

Thoughts / comments?

Activity

  1. michaelrsweet commented on Dec 7, 2017

    @michaelrsweet
    Contributor

    I hesitate to do anything like this, as it opens up potential security attacks.

    What operating systems are the Clients that are sending user names with this problem?

  2. self-assigned this
    on Dec 7, 2017
  3. jsmeix commented on Dec 8, 2017

    @jsmeix

    @michaelrsweet
    could you explain why such squashing non-UTF-8 into ASCII
    (for example replacing all non-ASCII bytes with 0x3F '?')
    opens up potential security attacks.

    My guess is that any automated change of bytes
    could also be intentionally misused by an attacker
    to get a maliciously crafted print job somehow accepted
    (and processed by cupsd plus various filters/backend,
    and finally by the (full-featured network) printer device)
    that would otherwise be (safely) rejected.

    FYI:

    This issue is a follow-up of
    #5143

    See my
    #5143 (comment)
    I still have no information what actually goes on
    in those (few) customer's environments where it happens.

    I guess that the admin who is responsible for the CUPS server
    has no influence on the client systems that submit print jobs
    with whatever invalid values and I guess that his boss
    or his users expect that "printing anything just works".

    To a certain extent I even agree. In particular I think that
    rejecting a job only because of an improperly encoded
    optional value is technically right and in compliance
    with the IPP specification but not user friendly.

    Therefore we (i.e. SUSE) are now thinking about
    if CUPS could be more liberal in what it accepts
    but of course only if more liberality would not make
    things less secure - and I agree with the "Criticism" in
    https://en.wikipedia.org/wiki/Robustness_principle

  4. michaelrsweet commented on Dec 8, 2017

    @michaelrsweet
    Contributor

    So, my main security concern is that something bad gets through. My secondary concern is that if we allow it then will we end up with DBUS or some other system component crashing cupsd because of a bad string?

    Also, if a Client gets the requesting-user-name wrong (!?!) then what else is going to be broken?

    We can probably tie this to the strict conformance setting - when not in strict conformance we can simply ignore requesting-user-name (and return it in the unsupported attributes group of the response) and treat the job as coming from "anonymous" unless it is otherwise authenticated (at which point we'll use the authenticated user name instead).

  5. added this to the milestone on Dec 8, 2017
  6. michaelrsweet commented on Dec 13, 2017

    @michaelrsweet
    Contributor

    [master 6d14c1b] The scheduler now substitutes default values for invalid job attributes when running in "relaxed conformance" mode (Issue #5186)

  7. jsmeix commented on Dec 15, 2017

    @jsmeix

    @michaelrsweet
    thank you for all your work and efforts with such weird issues!

  8. vliaskov commented on Jan 18, 2018

    @vliaskov
    Author

    Commit 6d14c1b now allows the add_job to be successfully submitted. However now the send_document job is aborted during validate_user() - we get:

    Returning HTTP Unauthorized for Send-Document

    It looks like send_document() - >validate_user() -> cupsdIsAuthorized() is picking up the original "bad" non-utf8 requesting-user-name, although this was replaced with "anonymous" in add_job with upstream fix 6d14c1b. So I assume the next jobs still get the original requesting-user-name, correct?

    If validate_user is commented out in send_document(), or if cupsdIsAuthorized() does the same check/replacement of requesting-user-name as commit 6d14c1b does in add_job, the problem is solved. However the first is a hack and the second code duplication.

    What is the preferred way to fix the requesting user name for all jobs? Is code duplication (substituting requesting-user-name with "anonymous" in cupsdIsAuthorized() enough? Or should the attribute checks be in a separate function that will somehow be used by jobs that need it?

  9. michaelrsweet commented on Jan 18, 2018

    @michaelrsweet
    Contributor

    @vliaskov Please file a new bug for this issue.

  10. jsmeix commented on Jan 19, 2018

    @jsmeix

    The new issue is
    #5229

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions