Skip to content

Commit a0f4edb

Browse files
authored
Merge pull request b3log#12331 from nanolikeyou/master
修复几项安全问题
2 parents dbf70a3 + 294ebb3 commit a0f4edb

File tree

4 files changed

+23
-8
lines changed

4 files changed

+23
-8
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
<jsoup.version>1.9.1</jsoup.version>
8383
<flexmark.version>0.22.16</flexmark.version>
8484
<qiniu.version>7.0.4.1</qiniu.version>
85-
<jetty.version>9.2.7.v20150116</jetty.version>
85+
<jetty.version>9.2.9.v20150224</jetty.version>
8686
<commons-cli.version>1.3.1</commons-cli.version>
8787
<emoji-java.version>3.2.0</emoji-java.version>
8888
<jodd.version>3.6.6</jodd.version>

src/main/java/org/b3log/solo/processor/FeedProcessor.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -417,11 +417,10 @@ private Item getItem(final JSONArray articles, final boolean hasMultipleUsers, S
417417
final String link = Latkes.getServePath() + article.getString(Article.ARTICLE_PERMALINK);
418418
ret.setLink(link);
419419
ret.setGUID(link);
420-
final String authorEmail = article.getString(Article.ARTICLE_AUTHOR_EMAIL);
421420
if (hasMultipleUsers) {
422421
authorName = StringEscapeUtils.escapeXml(articleQueryService.getAuthor(article).getString(User.USER_NAME));
423422
}
424-
ret.setAuthor(authorEmail + "(" + authorName + ")");
423+
ret.setAuthor(authorName);
425424
final String tagsString = article.getString(Article.ARTICLE_TAGS_REF);
426425
final String[] tagStrings = tagsString.split(",");
427426
for (final String tagString : tagStrings) {

src/main/java/org/b3log/solo/processor/LoginProcessor.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ public void showLogin(final HTTPRequestContext context) throws Exception {
146146
String destinationURL = request.getParameter(Common.GOTO);
147147
if (Strings.isEmptyOrNull(destinationURL)) {
148148
destinationURL = Latkes.getServePath() + Common.ADMIN_INDEX_URI;
149+
} else if (!isInternalLinks(destinationURL)) {
150+
destinationURL = "/";
149151
}
150152

151153
final HttpServletResponse response = context.getResponse();
@@ -244,7 +246,7 @@ public void logout(final HTTPRequestContext context) throws IOException {
244246

245247
String destinationURL = httpServletRequest.getParameter(Common.GOTO);
246248

247-
if (Strings.isEmptyOrNull(destinationURL)) {
249+
if (Strings.isEmptyOrNull(destinationURL) || !isInternalLinks(destinationURL)) {
248250
destinationURL = "/";
249251
}
250252

@@ -265,6 +267,8 @@ public void showForgot(final HTTPRequestContext context) throws Exception {
265267

266268
if (Strings.isEmptyOrNull(destinationURL)) {
267269
destinationURL = Latkes.getServePath() + Common.ADMIN_INDEX_URI;
270+
} else if (!isInternalLinks(destinationURL)) {
271+
destinationURL = "/";
268272
}
269273

270274
renderPage(context, "reset-pwd.ftl", destinationURL, request);
@@ -484,4 +488,15 @@ private void renderPage(final HTTPRequestContext context, final String pageTempl
484488
Keys.fillRuntime(dataModel);
485489
filler.fillMinified(dataModel);
486490
}
491+
492+
/**
493+
* Preventing unvalidated redirects and forwards¡£See more at:
494+
* <a>https://www.owasp.org/index.php/
495+
* Unvalidated_Redirects_and_Forwards_Cheat_Sheet</a>
496+
*
497+
* @return whether the destinationURL is an internal link
498+
*/
499+
private boolean isInternalLinks(String destinationURL) {
500+
return destinationURL.startsWith(Latkes.getServePath());
501+
}
487502
}

src/main/webapp/js/lib/jquery/jquery.min.js

Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)