GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [vf] CSRF in VF controller pages by sgorbaty · Pull Request #283 · pmd/pmd

Conversation

@sgorbaty

@sgorbaty sgorbaty commented Mar 2, 2017

Copy link
Copy Markdown
Contributor

This a new rule.
It detects presence of controller action called upon loading a page.
Normally each page has already CSRF protection in place but by calling this action the developer has 'busted' the CSRF protection and made the method called by action attribute vulnerable again.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@sergeygorbaty
CSRF in VF controller pages
799614e
@jsotuyod jsotuyod added the a:new-rule Proposal to add a new built-in rule label Mar 3, 2017
@jsotuyod jsotuyod added this to the 5.6.0 milestone Mar 3, 2017
@jsotuyod jsotuyod self-assigned this Mar 3, 2017
jsotuyod
jsotuyod requested changes Mar 3, 2017
View reviewed changes

@jsotuyod jsotuyod left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

@sgorbaty once again, thanks for the amazing contribution. I do have some minor issues on this occassion 'though

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread pmd-visualforce/src/main/java/net/sourceforge/pmd/lang/vf/rule/security/VfCsrfRule.java Outdated
}

if (action) {
ASTElExpression value = attr.getFirstDescendantOfType(ASTElExpression.class);

@jsotuyod jsotuyod Mar 3, 2017

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

shouldn't this block be directly within the case "action": block? I believe you just want to check the value of the action attribute, not all attributes after the action one

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread pmd-visualforce/src/main/resources/rulesets/vf/security.xml Outdated
</rule>


<rule name="VfCsrf" since="3.7" message="Avoid calling VF action upon page load"

@jsotuyod jsotuyod Mar 3, 2017

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

this should be since 5.6.0. I just fixed it for the VfUnescapeElRule

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread pmd-visualforce/src/test/resources/net/sourceforge/pmd/lang/vf/rule/security/xml/VfCsrf.xml
<?xml version="1.0" encoding="UTF-8"?>
<test-data>

<test-code>

@jsotuyod jsotuyod Mar 3, 2017

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

we should add at least 1 test case with correct code and 0 violations reported

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
jsotuyod and others added 6 commits March 3, 2017 16:02
@jsotuyod
Merge branch 'master' into CSRFInVisualForce
b3992a6
@sergeygorbaty
Review fixes
229a4d7
@sgorbaty
Update security.xml
d14f33e
Version # change
@sgorbaty
Positive test cases
3b873ce
Adding positive test cases to the rule
@sergeygorbaty
Merge branch 'CSRFInVisualForce' of github.com:sgorbaty/pmd into CSRF…
8ba0218
…InVisualForce
@sergeygorbaty
Small change
8ebd82b
jsotuyod
jsotuyod approved these changes Mar 4, 2017
View reviewed changes
jsotuyod added a commit to jsotuyod/pmd that referenced this pull request Mar 7, 2017
@jsotuyod
Update changelog, refs pmd#283
3b71d75
@jsotuyod
jsotuyod merged commit 8ebd82b into pmd:master Mar 7, 2017
@jsotuyod

jsotuyod commented Mar 7, 2017

Copy link
Copy Markdown
Member

Thanks! This will be included in PMD 5.6.0 and later

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@sgorbaty
sgorbaty deleted the CSRFInVisualForce branch April 13, 2017 23:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@jsotuyod jsotuyod jsotuyod approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@jsotuyod jsotuyod

Labels

a:new-rule Proposal to add a new built-in rule

Projects

None yet

Milestone

5.6.0

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@sgorbaty @jsotuyod @sergeygorbaty
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.