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

Obsolete literal AddColumn #3517

Conversation

fredericDelaporte
Copy link
Member

SqlInsert/UpdateBuilder AddColumn overloads taking a value have a SQL injection vulnerability, and have no usage.

@@ -66,6 +66,8 @@ public virtual SqlInsertBuilder AddColumn(string columnName, IType propertyType)
/// <param name="val">The value to set for the column.</param>
/// <param name="literalType">The NHibernateType to use to convert the value to a sql string.</param>
/// <returns>The SqlInsertBuilder.</returns>
// Since v5.6
[Obsolete("This method is unsafe and has no more usages. Use the overload with a property type and use a parameterized query.")]
public SqlInsertBuilder AddColumn(string columnName, object val, ILiteralType literalType)
{
return AddColumn(columnName, literalType.ObjectToSQLString(val, Dialect));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As noted by @gliljas in #3516, these methods implementations are unsafe and may lead to SQL injections or invalid SQL. Since these AddColumn overloads have no usage, better just obsolete them. Adding a literal value in a SQL query as a string fragment is anyway a bad practice. Parameterization should be used instead.

@fredericDelaporte
Copy link
Member Author

fredericDelaporte commented May 5, 2024

If we do that for mitigating some of the issues raised in #3516, it should target the currently released minor instead, I realized. Even if obsoleting members in a patch release is not a normal practice with SemVer, when that is a security issue mitigation, it seems reasonable.

If instead the trouble is fixed at its root in the minor release, then we could keep on targeting the next minor, with another obsolete message.

@hazzik
Copy link
Member

hazzik commented May 6, 2024

Let's do 5.4.x and 5.5.x

SqlInsert/UpdateBuilder AddColumn overloads taking a value have a SQL injection vulnerability, and have no usage.
@fredericDelaporte fredericDelaporte changed the base branch from master to 5.4.x May 9, 2024 12:46
@fredericDelaporte fredericDelaporte modified the milestones: 5.6, 5.4.9 May 9, 2024
@fredericDelaporte fredericDelaporte merged commit fdd7fcf into nhibernate:5.4.x May 11, 2024
22 of 23 checks passed
@fredericDelaporte fredericDelaporte deleted the obsolete-add-literal-column branch May 11, 2024 20:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants