cfquery accepting old passwords

Ask a Question related to Coldfusion Database Access, Design and Development.

  1. #1

    Default cfquery accepting old passwords

    After users change their passwords, fcqueries accept both new and old
    passwords. Other passwords are rejected. How do I inform MacroMedia about
    this problem? This is a MX7 security risk we should all be aware of.

    I am using ColdFusion MX7 on XP, MS server2000 with SQL Server Authentication.
    Attached is a simple example that demonstrates a cfquery accepting both new
    and old passwords.

    How to run the example:
    Set user ?f? password to ?pw1?
    Then change the password to ?pw2?
    Then run the attached cfqueries

    Results:
    Both passwords ?pw1? and ?pw2? are accepted.
    The invalid password ?pw3? is rejected
    Logging out and then logging back in makes no difference
    MS Query Analyzer accepts only the new password ?pw2?
    After rebooting or timing out, cfquery rejects the old passwords
    This only happens in MX7. MX6 does not do this.

    Conclusion:
    MX7 cfquery is not secure if a user changes password after password is
    compromised.


    <!--- test old password --->
    <cfquery name=?getUser1? datasource=?#application#?
    username=?#session.username#? password=?pw1?>
    SELECT username FROM USERS
    WHERE username=?f?
    </cfquery>
    Old password: username = <cfoutput># getUser1.username#</cfoutput><br>

    <!--- test new password --->
    <cfquery name=?getUser2? datasource=?#application#?
    username=?#session.username#? password=?pw2?>
    SELECT username FROM USERS
    WHERE username=?f?
    </cfquery>
    Old password: username = <cfoutput># getUser2.username#</cfoutput><br>

    <!--- test invalid password --->
    <cfquery name=?getUser3? datasource=?#application#?
    username=?#session.username#? password=?pw3?>
    SELECT username FROM USERS
    WHERE username=?f?
    </cfquery> <!--- Login failed. --->

    wolfv Guest

  2. Similar Questions and Discussions

    1. Not accepting connections
      My problem is exactly the same as what has been described here except that once a page is being edited, they get the "Contribute could not connect...
    2. cfquery accepting old passwords in MX7
      After users change their passwords, fcqueries accept the old passwords. Old passwords are rejected after rebooting or timing out. MX6 does not do...
    3. Webservice Accepting XML
      Can anyone point me to any resources/examples on how to build a webservice that accepts an xml file. I have customers who need to update a...
    4. Accepting data from URL Parameters
      I appologize for what may be a newbie-like request, but I have not been able to find this information in the PHP documentation. If I were to have...
    5. cannot connect to accepting sockets...
      hello all, I am writing a Gtk (well Gtkmm actually) version of othello that has aspirations of being networkable, but I am having a little...
  3. #2

    Default Re: cfquery accepting old passwords

    Where is the part where you update the user's password in your db?
    Dan Bracuk Guest

  4. #3

    Default Re: cfquery accepting old passwords

    I cannot see anything wrong with the way MX7 handles the passwords. You observe
    that behaviour because your code contains an error and a misunderstanding.

    First, the error. The username attribute of the cfquery tag is the one, and
    only one ,
    username that you have registered for the
    datasourcename(datasource=?#application#?)
    in the Coldfusion Administrator. As such it should not be a session variable.
    Since the
    datasourcename is at least of Application scope, so too are the other cfquery
    attributes,
    username and password. They usually remain fixed throughout the Application's
    lifetime.
    The session code you use might sometimes work, but it is in general not
    correct. That
    might explain the inconsistencies you notice when you reboot or when sessions
    time out.

    An example to illustrate. When a client's session expires you might wish to
    store some
    closing information in the database, for example, by running an insert-query
    in
    Application.cfc's onSessionEnd method. Your code would not be able to do that
    when
    session.username becomes undefined at the end of a session.

    Second, the misunderstanding. You seem to confuse the login credentials of the
    user
    and those of the datasource. The username/password attributes in the cfquery
    tag
    are used by Coldfusion to log on to the database server. They have nothing to
    do
    with the user who is currently logged in or with the contents of the USERS
    table.
    To get the username/password combination for the user, apply code like

    <cfloginuser name="user_name" password="user_password" roles="user_role">

    or

    <cfquery name=?getUser1? datasource=?datasourceName? username=?DSN_username?
    password=?DSN_password?>
    SELECT uname, pword FROM USERS
    WHERE uname=?f?
    </cfquery>


    BKBK Guest

  5. #4

    Default Re: cfquery accepting old passwords

    I changed the password via MS Enterprise Manager or the following cfquery.
    Either way, the old password is accepted. Since the above example, I have
    replaced all application and session variables with string literals.

    The following example is a very simple demonstration of MX7 cfquery accepting
    an old password.


    <!--- change password from 'pw1' to 'pw2' --->
    <cfquery datasource="demo" username="f" password="pw1">
    sp_password 'pw','pw2'
    </cfquery>

    <!--- old password is accepted --->
    <cfquery name="getUser1" datasource="demo" username="f" password="pw1">
    SELECT username FROM USERS WHERE username='f'
    </cfquery>
    Old password: username = <cfoutput>#getUser1.username#</cfoutput><br>

    <!--- new password is accepted --->
    <cfquery name="getUser2" datasource="demo" username="f" password="pw2">
    SELECT username FROM USERS WHERE username='f'
    </cfquery>
    new password: username = <cfoutput>#getUser2.username#</cfoutput><br>

    <!--- invalid password is rejected --->
    <cfquery name="getUser3" datasource="demo" username="f" password="pw3">
    SELECT username FROM USERS WHERE username='f'
    </cfquery>

    wolfv Guest

  6. #5

    Default Re: cfquery accepting old passwords

    sp_password 'pw','pw2' contains an error. It should be sp_password 'pw1','pw2'.
    BKBK Guest

  7. #6

    Default Re: cfquery accepting old passwords

    BKBK
    Your right. the first cfquery should read
    sp_password 'pw1','pw2'

    Thanks for pointing that out.

    wolfv Guest

  8. #7

    Default Re: cfquery accepting old passwords

    Sorry about the typo in the previous example. The corrected version is below.

    This simple example demonstrates cfquery accepting an old password.


    <!--- change password from 'pw1' to 'pw2' --->
    <cfquery datasource="demo" username="f" password="pw1">
    sp_password 'pw1','pw2'
    </cfquery>

    <!--- old password is accepted --->
    <cfquery name="getUser1" datasource="demo" username="f" password="pw1">
    SELECT username FROM USERS WHERE username='f'
    </cfquery>
    Old password: username = <cfoutput>#getUser1.username#</cfoutput><br>

    <!--- new password is accepted --->
    <cfquery name="getUser2" datasource="demo" username="f" password="pw2">
    SELECT username FROM USERS WHERE username='f'
    </cfquery>
    new password: username = <cfoutput>#getUser2.username#</cfoutput><br>

    <!--- invalid password is rejected --->
    <cfquery name="getUser3" datasource="demo" username="f" password="pw3">
    SELECT username FROM USERS WHERE username='f'
    </cfquery>

    wolfv Guest

  9. #8

    Default Re: cfquery accepting old passwords

    <!--- change password from 'pw1' to 'pw2' --->
    <cfquery datasource="demo" username="f" password="pw1">
    sp_password 'pw1','pw2'
    </cfquery>
    We're already on to a bad start here. The tag to run stored procedures is
    <cfstoredproc>, not <cfquery>.

    This simple example demonstrates cfquery accepting an old password.
    No. It demonstrates the MS SQL server accepting an old password, as Coldfusion
    uses the password to log on to the MS SQL server.



    BKBK Guest

  10. #9

    Default Re: cfquery accepting old passwords

    After running the above example, Query Analyzer accepted the new password but
    not the old password. Which leads me to suspect it?s a problem with cfquery,
    possibly only with Server2000.

    Thank you for testing it on your system BKBK.

    sp_password is a Transact-SQL stored procedure. I tried it in cfstoredproc
    tags but got the error ?The page cannot be displayed.?

    <!--- change password from 'pw1' to 'pw2' --->
    <cfstoredproc procedure="sp_password" datasource="demo" username="f"
    password="pw1">
    <cfprocparam value="pw1" cfsqltype="cf_sql_varchar">
    <cfprocparam value="pw2" cfsqltype="cf_sql_varchar">
    <!--- <cfprocparam value="f" cfsqltype="cf_sql_varchar"> --->
    </cfstoredproc >

    wolfv Guest

  11. #10

    Default Re: cfquery accepting old passwords

    After running the above example, Query Analyzer accepted the new password but not the old password. Which leads me to suspect it?s a problem with cfquery
    Hmmm... more complicated than I had thought.


    BKBK Guest

  12. #11

    Default Re: cfquery accepting old passwords

    it sounds to me like connection pooling. see
    [url]http://www.talkingtree.com/blog/index.cfm/2005/3/14/ConnPooling1[/url] for a
    good explanation

    HTH,
    Tim
    --
    Tim Carley
    [url]www.recfusion.com[/url]
    [email]info@NOSPAMINGrecfusion.com[/email]
    Mountain Lover Guest

  13. #12

    Default Re: cfquery accepting old passwords

    Thanks, Mountain Lover.

    It sometimes takes someone else lighting the torch. Seeing your "connection
    pooling" sparked the aha moment. Everything immediately made sense.

    By default, a single request may only make one connection to a database at a
    time. However, a request can have, available to it, a connection pool of, say,
    5 connections, each pool being identified by the distinct combination of
    username/password, database server and database.

    Wolfv's page amounts to one Coldfusion request. It will therefore only make
    one connection to the database at a time. In fact, the page opens within a
    connection pool that uses the original username/password combination. The
    first two queries run within this pool.

    However, when Coldfusion encounters a new username/password, the request
    disconnects from the database and then re-connects. The new connection belongs
    to a new connection pool, created to distinguish any new set of connections
    from the original. The third query runs within this pool.



    BKBK Guest

  14. #13

    Default Re: cfquery accepting old passwords

    Thanks Newsgroup User. That explains a lot.

    I unchecked ?Maintain Connection? and now my application does not accept any
    old passwords. Problem solved.

    But there is still something I don?t understand. My little demonstration
    above, still accepts the old password. Go figure.


    wolfv Guest

  15. #14

    Default Re: cfquery accepting old passwords

    > My little demonstration above, still accepts the old password.
    It does not . The word "old" is the source of the confusion. You switch
    connection pools, and your demonstration simply accepts the password of the
    current pool.



    BKBK Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139