Title: Quoted usernames are not supported · Issue #920 · utPLSQL/utPLSQL · GitHub
Open Graph Title: Quoted usernames are not supported · Issue #920 · utPLSQL/utPLSQL
X Title: Quoted usernames are not supported · Issue #920 · utPLSQL/utPLSQL
Description: Description An unfriendly DBA could inject SQL by creating a user. All parts building up a dynamic SQL or PL/SQL statements must be asserted accordingly. Even expressions like sys_context('userenv','current_schema'). Special thanks to @k...
Open Graph Description: Description An unfriendly DBA could inject SQL by creating a user. All parts building up a dynamic SQL or PL/SQL statements must be asserted accordingly. Even expressions like sys_context('userenv'...
X Description: Description An unfriendly DBA could inject SQL by creating a user. All parts building up a dynamic SQL or PL/SQL statements must be asserted accordingly. Even expressions like sys_context('user...
Opengraph URL: https://github.com/utPLSQL/utPLSQL/issues/920
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Quoted usernames are not supported","articleBody":"### Description\r\n\r\nAn unfriendly DBA could inject SQL by creating a user. All parts building up a dynamic SQL or PL/SQL statements must be asserted accordingly. Even expressions like `sys_context('userenv','current_schema')`. Special thanks to @krisrice for pointing that out.\r\n\r\n### utPLSQL Version\r\n\r\nv3.1.7.2808-develop\r\n\r\n### To Reproduce\r\n\r\n#### 1. Create user\r\n\r\n```\r\ncreate user \";drop table t;\" identified by \"demo\";\r\ngrant connect, resource to \";drop table t;\"\r\n```\r\n\r\n#### 2. Create test\r\n\r\n```\r\nconnect \";drop table emp;\"/demo\r\n\r\ncreate table t (c varchar2(10 char));\r\n\r\ncreate or replace package test_p is\r\n\r\n --%suite\r\n\r\n --%test\r\n procedure p;\r\n \r\nend test_p;\r\n/\r\n\r\ncreate or replace package body test_p is\r\n\r\n procedure p is\r\n begin\r\n ut.expect(1).to_equal(1);\r\n end p;\r\n \r\nend test_p;\r\n/\r\n```\r\n\r\n### Run Test\r\n\r\n```\r\nset serveroutput on size unlimited\r\nexecute ut.run(ut_varchar2_list());\r\n```\r\n\r\nThe server output is: \r\n\r\n```\r\nORA-06512: at \"UT3_LATEST_RELEASE.UT_SUITE_MANAGER\", line 45\r\nORA-06512: at \"UT3_LATEST_RELEASE.UT_SUITE_MANAGER\", line 69\r\nORA-06512: at \"UT3_LATEST_RELEASE.UT_SUITE_MANAGER\", line 652\r\nORA-06512: at \"UT3_LATEST_RELEASE.UT_RUNNER\", line 136\r\n\r\nORA-20202: Invalid path format: ;drop table t;\r\nORA-06512: at \"UT3_LATEST_RELEASE.UT_SUITE_MANAGER\", line 45\r\nORA-06512: at \"UT3_LATEST_RELEASE.UT_SUITE_MANAGER\", line 69\r\nORA-06512: at \"UT3_LATEST_RELEASE.UT_SUITE_MANAGER\", line 652\r\n\r\n\r\n\r\nError starting at line : 2 in command -\r\nBEGIN ut.run(ut_varchar2_list()); END;\r\nError report -\r\nORA-20202: Invalid path format: ;drop table t;\r\nORA-06512: at \"UT3_LATEST_RELEASE.UT_RUNNER\", line 172\r\nORA-06512: at \"UT3_LATEST_RELEASE.UT_SUITE_MANAGER\", line 45\r\nORA-06512: at \"UT3_LATEST_RELEASE.UT_SUITE_MANAGER\", line 69\r\nORA-06512: at \"UT3_LATEST_RELEASE.UT_SUITE_MANAGER\", line 652\r\nORA-06512: at \"UT3_LATEST_RELEASE.UT_RUNNER\", line 136\r\nORA-06512: at \"UT3_LATEST_RELEASE.UT\", line 128\r\nORA-06512: at \"UT3_LATEST_RELEASE.UT\", line 465\r\nORA-06512: at line 1\r\n```\r\n\r\nIn this case the test just failed without side effects. However, it shows two things:\r\n\r\na) utPLSQL expects and supports certain style of usernames only (no enquoted user names)\r\n\r\nb) the potential risks of SQL injection.\r\n\r\n\r\n### Expected Behavior\r\n\r\nThe test case above works. 1 test executed successfully.\r\n\r\n\r\n### Additional Context\r\n\r\n@krisrice suggested to change the code in [ut_utils.pkb](https://github.com/utPLSQL/utPLSQL/blob/467078f121f2410638fc71ec7b81eed26bf38dd7/source/core/ut_utils.pkb#L550)\r\n\r\nfrom \r\n\r\n```\r\n function ut_owner return varchar2 is\r\n begin\r\n return sys_context('userenv','current_schema');\r\n end;\r\n```\r\n\r\nto \r\n\r\n```\r\n function ut_owner return varchar2 is\r\n begin\r\n return sys.dbms_assert.enquote_name(sys_context('userenv','current_schema'));\r\n end;\r\n```\r\n","author":{"url":"https://github.com/PhilippSalvisberg","@type":"Person","name":"PhilippSalvisberg"},"datePublished":"2019-05-11T16:08:28.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/920/utPLSQL/issues/920"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:4984d3ca-24da-7440-2aee-38faf335bbef |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D174:20E33D:92B097:D1F118:6A6382B1 |
| html-safe-nonce | ef00369c59182d80a73daf5da825ea287b33f1ab8642f6a9eb690089b8fb7bd4 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMTc0OjIwRTMzRDo5MkIwOTc6RDFGMTE4OjZBNjM4MkIxIiwidmlzaXRvcl9pZCI6IjM1Nzk0NDEzNDEyOTc1NTgxOTMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 6686cf913d347e2a04b0288649e4f09d3c81e3fb2cfda96143d4014ee01a52bc |
| hovercard-subject-tag | issue:443010044 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/utPLSQL/utPLSQL/920/issue_layout |
| twitter:image | https://opengraph.githubassets.com/6708c3070dc413e87dde3e9735365502c1535f24d8d0da95cb649a0f70adc844/utPLSQL/utPLSQL/issues/920 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/6708c3070dc413e87dde3e9735365502c1535f24d8d0da95cb649a0f70adc844/utPLSQL/utPLSQL/issues/920 |
| og:image:alt | Description An unfriendly DBA could inject SQL by creating a user. All parts building up a dynamic SQL or PL/SQL statements must be asserted accordingly. Even expressions like sys_context('userenv'... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | PhilippSalvisberg |
| hostname | github.com |
| expected-hostname | github.com |
| None | e4fb64aef87da454ec25b158147f7f5f14aef29216e5ca1612c2e48faa599d1f |
| turbo-cache-control | no-preview |
| go-import | github.com/utPLSQL/utPLSQL git https://github.com/utPLSQL/utPLSQL.git |
| octolytics-dimension-user_id | 15661281 |
| octolytics-dimension-user_login | utPLSQL |
| octolytics-dimension-repository_id | 50728220 |
| octolytics-dimension-repository_nwo | utPLSQL/utPLSQL |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 50728220 |
| octolytics-dimension-repository_network_root_nwo | utPLSQL/utPLSQL |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | e839936ba5faffb9c836dda1cf4729d50c88a32e |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width