New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 757951 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Closed: Today
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 2
Type: Bug



Sign in to add a comment

Sanitize URIs in DebugDaemon when adding printers

Project Member Reported by skau@chromium.org, Aug 22 2017

Issue description

DebugDaemon should try to ensure that uris are reasonably valid before passing values to lpadmin.  CUPS rejects these uris as expected but we can report better errors if we catch it earlier.

 

Comment 1 by skau@chromium.org, Dec 2 2017

Cc: skau@chromium.org
Labels: -M-63 M-65
Owner: valleau@chromium.org
Status: Assigned (was: Untriaged)
The errors from lpadmin are generally okay.  We should ensure uri is non-empty though.

Comment 2 by skau@chromium.org, Dec 2 2017

Path to CupsTool src/platform2/debugd/src/cups_tool.cc
If CUPS hex-encodes all characters that are not in the valid ASCII range, what are the possible invalid cases to consider aside from an empty URI?

Should we strictly verify that the URIs match the expected format of the ipp/ippusb schemes, since those are the only schemes we would use for ipp everywhere printing?
Labels: -M-65 M-66
Labels: -M-66 M-67
Cc: valleau@chromium.org
Labels: -M-67
Owner: ----
Status: Available (was: Assigned)
Labels: Bolton-CodeHealth
Owner: kd...@chromium.org
Status: Assigned (was: Available)
For this bug, what defines a "reasonably valid" URI? My guess is that it
1. starts with a known URI scheme and
2. is percent-encoded appropriately per Justin's code.

Does that seem fair?
Yes.  That assessment is fair.  However, you can be stricter than justin where if you see anything that would need to be hex encoded, just reject the uri as invalid.
Status: Started (was: Assigned)
Project Member

Comment 13 by bugdroid1@chromium.org, Jan 19 (4 days ago)

The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/platform2/+/bc26ba99d377a0dafac046439e4389c9717b5ed9

commit bc26ba99d377a0dafac046439e4389c9717b5ed9
Author: Kalvin Lee <kdlee@chromium.org>
Date: Sat Jan 19 04:05:09 2019

debugd: Sanitize print URIs before calling lpadmin

When adding printers, we reject percents, spaces, and non-ASCII
characters in the URI. This logic mirrors Chrome browser's
CupsURIEscape. In addition, we reject empty URIs.

BUG= chromium:757951 
TEST=Wrote and ran unit tests
CQ-DEPEND=CL:1419238

Change-Id: I3b6cd4b81b6c6cfcc08cbc56e38335105955f4a1
Reviewed-on: https://chromium-review.googlesource.com/1412221
Commit-Ready: Kalvin Lee <kdlee@chromium.org>
Tested-by: Kalvin Lee <kdlee@chromium.org>
Reviewed-by: David Valleau <valleau@chromium.org>

[modify] https://crrev.com/bc26ba99d377a0dafac046439e4389c9717b5ed9/debugd/BUILD.gn
[modify] https://crrev.com/bc26ba99d377a0dafac046439e4389c9717b5ed9/debugd/src/cups_tool.cc
[modify] https://crrev.com/bc26ba99d377a0dafac046439e4389c9717b5ed9/system_api/dbus/debugd/dbus-constants.h
[add] https://crrev.com/bc26ba99d377a0dafac046439e4389c9717b5ed9/debugd/src/cups_tool_test.cc
[modify] https://crrev.com/bc26ba99d377a0dafac046439e4389c9717b5ed9/debugd/src/cups_tool.h

Project Member

Comment 14 by bugdroid1@chromium.org, Jan 19 (4 days ago)

The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/third_party/autotest/+/8a93f17c822ff3655e4e94a684f8c606e730e680

commit 8a93f17c822ff3655e4e94a684f8c606e730e680
Author: Kalvin Lee <kdlee@chromium.org>
Date: Sat Jan 19 04:05:09 2019

debugd autotest: distinguish bad URIs when configuring printers

Amend the DebugDaemon autotest to catch the specific bad URI error code
newly added as a guard against calling lpadmin with an obviously bad
URI.

BUG= chromium:757951 
TEST=Passed applicable autotests matching pattern "e:platform_DebugDaemon.+"
CQ-DEPEND=CL:1412221

Change-Id: Ic92867f4cf8fc0a33f14cf2e2c5ce318b9a4885f
Reviewed-on: https://chromium-review.googlesource.com/1419238
Commit-Ready: Kalvin Lee <kdlee@chromium.org>
Tested-by: Kalvin Lee <kdlee@chromium.org>
Reviewed-by: Luigi Semenzato <semenzato@chromium.org>
Reviewed-by: David Valleau <valleau@chromium.org>

[modify] https://crrev.com/8a93f17c822ff3655e4e94a684f8c606e730e680/client/site_tests/platform_DebugDaemonCupsAddPrinters/platform_DebugDaemonCupsAddPrinters.py

Comment 15 by skau@chromium.org, Today (19 hours ago)

Fixed?

Comment 16 by kd...@chromium.org, Today (19 hours ago)

Status: Fixed (was: Started)
There's an outstanding review in Gerrit for the changes mirrored to dbus-constants.h in the Chromium tree. Other than that, I reckon this is fixed.

Sign in to add a comment