Note: Software Developer (Programmer) with Human Resources Skills here.
Quick and Short Answer
Yes, you should give an honest (impartial) feedback about a colleague's qualities.
When applied to recruiting, is OK to mention bad qualities ( "Things that can be improved" ), as well that good qualities.
But, is important, the way you tell the recruiter about a coworker, to make a difference between an honest, impartial review with a bad result, and plain badmouthing.
Long Boring Extended Answer
Yes, you should give an honest (impartial) feedback about a colleague's qualities.
But, there is a difference in how you explain to a recruiter, how your coworker, performs, whether is explicit badmouthing, impartial review with bad results, and, the worse type: the "hidden" badmouthing (that looks like impartial review ).
In the "other hand", there are a lot of poor performance managers / developers who started as programmers, that conflict with their coworkers performance, because the employee (s) who promote them did not consider their bad features, whether, were informed or were not informed.
There are a lot of Human Resources Recruiters that see any bad comment from others, as a sign of badmouthing, which I believe is a mistake.
So, your concern, about getting into trouble, and being mistaken, as a "workplacer badmouther", is very legitimate.
And, companies, who want to get rid off an employee, but, doesn't want to get into trouble, and just "help" other companies to hire them.
Anyway, I have seen several companies, whom explicitly hire employees, with "caveats", because, they just require them.
Human Resources and Recruitment is, in deed, a complex difficult, job.
Subjective opinions become objective opinions, and vice versa.