Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected warnings in cfquery tag #64

Closed
laserbyte opened this issue Jun 25, 2015 · 5 comments
Closed

Unexpected warnings in cfquery tag #64

laserbyte opened this issue Jun 25, 2015 · 5 comments

Comments

@laserbyte
Copy link

I'm using MySQL comments in my code like the following cfquery statement to track the filename and the current line number for easier cross referencing in MySQL's query log.

<cfquery name="QueryName" datasource="#datasourceName#">
    -- QueryName - #GetFileFromPath(GetCurrentTemplatePath())# #this.instance.getCurrentLineNumber()#
    select * from tablename;
</cfquery>

However when I use these I'm getting warnings like this:

<cfquery name="GetFileFromPath(GetCurrentTemplatePath())"> should use <cfqueryparam/> for security reasons.
<cfquery name="this.instance.getCurrentLineNumber()"> should use <cfqueryparam/> for security reasons.
@ryaneberly
Copy link
Contributor

in #65, I changed the warning to correctly name the query.

These inline comments with hashes can still be considered a "risk". Even within SQL comments. Though your particular use of it is probably quite safe from injection. I recommend you either disable that message code entirely or on a case-by-case basis (per file, per line)

@jjames967
Copy link
Collaborator

Was your question answered LaserByte? It was set up as a warning to let you know that parameters should be designated as types (cf_sql_char, etc) for security reasons. http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec22c24-7c36.html

@laserbyte
Copy link
Author

I think so.

As a clarification I've been writing the queries like this now:

<cftransaction>
    <cfquery name="qSetParameter" datasource="#datasourceName#">
        SET @queryparam = <cfqueryparam value="#tablename#" />;
    </cfquery>

    <cfquery name="qGetData" datasource="#datasourceName#">
        select * from @queryparam;
    </cfquery>
</cftransaction>

Does this seem like the best approach for preventing SQL injection?

@jjames967
Copy link
Collaborator

<cfquery name="EmpList" datasource="cfdocexamples"> SELECT * FROM Employee WHERE Emp_ID = <cfqueryparam value = "#Emp_ID#" cfsqltype = "cf_sql_integer"> </cfquery>

adding the sql type adds the sql prevention attack.

@ryaneberly
Copy link
Contributor

closing. I think this is all set

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants