hitoshura25/cvefixes huggingface dataset:
CVE-2023-1237 (Other, published 2023-03-07T08:15Z)
Description: value: Cross-site Scripting (XSS) - Stored in GitHub repository answerdev/answer prior to 1.0.6.
Severity: nan (CVSS v3 base score: 5.4)
Weakness: CWE-79 \u2014 Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
Repository: https://github.com/answerdev/answer
Files changed:
ui/src/components/Comment/index.tsx
Commit message: fix(comment): Resolving xss issues in comments


Vulnerable code:
import { marked } from 'marked';
    const html = marked.parse(commentMarkDown);
    // if (!commentMarkDown || !html) {
    //   return;
    // }
      parsed_text: html,
      }).then(() => {
              comment.parsed_text = html;
              comment.original_text = item.value;

Fixed code:

      }).then((res) => {
              comment.parsed_text = res.parsed_text;
              comment.original_text = res.original_text;
CVE-2023-1238 (Other, published 2023-03-07T08:15Z)
Description: value: Cross-site Scripting (XSS) - Stored in GitHub repository answerdev/answer prior to 1.0.6.
Severity: nan (CVSS v3 base score: 5.4)
Weakness: CWE-79 \u2014 Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
Repository: https://github.com/answerdev/answer
Files changed:
ui/src/components/Comment/index.tsx
Commit message: fix(comment): Resolving xss issues in comments


Vulnerable code:
import { marked } from 'marked';
    const html = marked.parse(commentMarkDown);
    // if (!commentMarkDown || !html) {
    //   return;
    // }
      parsed_text: html,
      }).then(() => {
              comment.parsed_text = html;
              comment.original_text = item.value;

Fixed code:

      }).then((res) => {
              comment.parsed_text = res.parsed_text;
              comment.original_text = res.original_text;
CVE-2023-1239 (Go, published 2023-03-07T08:15Z)
Description: value: Cross-site Scripting (XSS) - Reflected in GitHub repository answerdev/answer prior to 1.0.6.
Severity: nan (CVSS v3 base score: 4.8)
Weakness: CWE-79 \u2014 Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
Repository: https://github.com/answerdev/answer
Files changed:
internal/install/install_req.go
Commit message: update site_name sanitizer


Vulnerable code:
	SiteName      string `validate:"required,gt=0,lte=30" json:"site_name"`

Fixed code:
	SiteName      string `validate:"required,sanitizer,gt=0,lte=30" json:"site_name"`
CVE-2023-1240 (Go, published 2023-03-07T08:15Z)
Description: value: Cross-site Scripting (XSS) - Stored in GitHub repository answerdev/answer prior to 1.0.6.
Severity: nan (CVSS v3 base score: 5.4)
Weakness: CWE-79 \u2014 Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
Repository: https://github.com/answerdev/answer
Files changed:
internal/schema/tag_schema.go
Commit message: update GetExcerpt


Vulnerable code:
	excerpt := strings.TrimSpace(tr.OriginalText)

Fixed code:
	excerpt := strings.TrimSpace(tr.ParsedText)
CVE-2023-1241 (Go, published 2023-03-07T08:15Z)
Description: value: Cross-site Scripting (XSS) - Stored in GitHub repository answerdev/answer prior to 1.0.6.
Severity: nan (CVSS v3 base score: 5.4)
Weakness: CWE-79 \u2014 Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
Repository: https://github.com/answerdev/answer
Files changed:
internal/schema/tag_schema.go
Commit message: update GetExcerpt


Vulnerable code:
	excerpt := strings.TrimSpace(tr.OriginalText)

Fixed code:
	excerpt := strings.TrimSpace(tr.ParsedText)
CVE-2023-1242 (Go, published 2023-03-07T08:15Z)
Description: value: Cross-site Scripting (XSS) - Stored in GitHub repository answerdev/answer prior to 1.0.6.
Severity: nan (CVSS v3 base score: 5.4)
Weakness: CWE-79 \u2014 Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
Repository: https://github.com/answerdev/answer
Files changed:
internal/schema/tag_schema.go
Commit message: update GetExcerpt


Vulnerable code:
	excerpt := strings.TrimSpace(tr.OriginalText)

Fixed code:
	excerpt := strings.TrimSpace(tr.ParsedText)
CVE-2023-1243 (Go, published 2023-03-07T08:15Z)
Description: value: Cross-site Scripting (XSS) - Stored in GitHub repository answerdev/answer prior to 1.0.6.
Severity: nan (CVSS v3 base score: 4.8)
Weakness: CWE-79 \u2014 Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
Repository: https://github.com/answerdev/answer
Files changed:
internal/install/install_req.go
Commit message: update site_name sanitizer


Vulnerable code:
	SiteName      string `validate:"required,gt=0,lte=30" json:"site_name"`

Fixed code:
	SiteName      string `validate:"required,sanitizer,gt=0,lte=30" json:"site_name"`
CVE-2023-1244 (Go, published 2023-03-07T08:15Z)
Description: value: Cross-site Scripting (XSS) - Stored in GitHub repository answerdev/answer prior to 1.0.6.
Severity: nan (CVSS v3 base score: 5.4)
Weakness: CWE-79 \u2014 Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
Repository: https://github.com/answerdev/answer
Files changed:
internal/install/install_req.go
Commit message: update site_name sanitizer


Vulnerable code:
	SiteName      string `validate:"required,gt=0,lte=30" json:"site_name"`

Fixed code:
	SiteName      string `validate:"required,sanitizer,gt=0,lte=30" json:"site_name"`
CVE-2023-1245 (Go, published 2023-03-07T08:15Z)
Description: value: Cross-site Scripting (XSS) - Stored in GitHub repository answerdev/answer prior to 1.0.6.
Severity: nan (CVSS v3 base score: 5.4)
Weakness: CWE-79 \u2014 Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
Repository: https://github.com/answerdev/answer
Files changed:
internal/schema/user_schema.go
pkg/converter/markdown.go
Commit message: update user about me markdown


Vulnerable code:
	req.BioHTML = converter.Markdown2HTML(req.Bio)

Fixed code:
	req.BioHTML = converter.Markdown2BasicHTML(req.Bio)
// Markdown2BasicHTML convert markdown to html ,Only basic syntax can be used
func Markdown2BasicHTML(source string) string {
	content := Markdown2HTML(source)
	filter := bluemonday.NewPolicy()
	filter.AllowElements("p", "b", "br")
	filter.AllowAttrs("src").OnElements("img")
	filter.AddSpaceWhenStrippingTag(true)
	content = filter.Sanitize(content)
	return content
}
CVE-2023-1535 (Go, published 2023-03-21T05:15Z)
Description: value: Cross-site Scripting (XSS) - Stored in GitHub repository answerdev/answer prior to 1.0.7.
Severity: nan (CVSS v3 base score: 5.4)
Weakness: CWE-79 \u2014 Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
Repository: https://github.com/answerdev/answer
Files changed:
pkg/converter/markdown.go
Commit message: update markdown xss


Vulnerable code:
	return buf.String()

Fixed code:
	html := buf.String()
	filter := bluemonday.NewPolicy()
	html = filter.Sanitize(html)
	return html
CVE-2023-1536 (Go, published 2023-03-21T05:15Z)
Description: value: Cross-site Scripting (XSS) - Stored in GitHub repository answerdev/answer prior to 1.0.7.
Severity: nan (CVSS v3 base score: 5.4)
Weakness: CWE-79 \u2014 Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
Repository: https://github.com/answerdev/answer
Files changed:
pkg/converter/markdown.go
Commit message: update markdown xss


Vulnerable code:
	return buf.String()

Fixed code:
	html := buf.String()
	filter := bluemonday.NewPolicy()
	html = filter.Sanitize(html)
	return html
CVE-2023-1537 (Go, published 2023-03-21T05:15Z)
Description: value: Authentication Bypass by Capture-replay in GitHub repository answerdev/answer prior to 1.0.6.
Severity: nan (CVSS v3 base score: 9.8)
Weakness: CWE-294 \u2014 Authentication Bypass by Capture-replay
A capture-replay flaw exists when the design of the product makes it possible for a malicious user to sniff network traffic and bypass authentication by replaying it to the server in question to the same effect as the original message (or with minor changes).
Repository: https://github.com/answerdev/answer
Files changed:
internal/repo/captcha/captcha.go
internal/service/action/captcha_service.go
Commit message: update VerifyCaptcha


Vulnerable code:

Fixed code:

func (cr *captchaRepo) DelCaptcha(ctx context.Context, key string) (err error) {
	err = cr.data.Cache.Del(ctx, key)
	if err != nil {
		log.Debug(err)
	}
	return nil
}
	DelCaptcha(ctx context.Context, key string) (err error)
		log.Error("VerifyCaptcha GetCaptcha Error", err.Error())
		return false, nil
	}
	err = cs.captchaRepo.DelCaptcha(ctx, key)
	if err != nil {
		log.Error("VerifyCaptcha DelCaptcha Error", err.Error())
CVE-2023-1538 (Go, published 2023-03-21T05:15Z)
Description: value: Observable Timing Discrepancy in GitHub repository answerdev/answer prior to 1.0.6.
Severity: nan (CVSS v3 base score: 5.3)
Weakness: CWE-203 \u2014 Observable Discrepancy
The product behaves differently or sends different responses under different circumstances in a way that is observable to an unauthorized actor, which exposes security-relevant information about the state of the product, such as whether a particular operation was successful or not.
Repository: https://github.com/answerdev/answer
Files changed:
internal/repo/captcha/captcha.go
internal/service/action/captcha_service.go
Commit message: update VerifyCaptcha


Vulnerable code:

Fixed code:

func (cr *captchaRepo) DelCaptcha(ctx context.Context, key string) (err error) {
	err = cr.data.Cache.Del(ctx, key)
	if err != nil {
		log.Debug(err)
	}
	return nil
}
	DelCaptcha(ctx context.Context, key string) (err error)
		log.Error("VerifyCaptcha GetCaptcha Error", err.Error())
		return false, nil
	}
	err = cs.captchaRepo.DelCaptcha(ctx, key)
	if err != nil {
		log.Error("VerifyCaptcha DelCaptcha Error", err.Error())
CVE-2023-1539 (Go, published 2023-03-21T05:15Z)
Description: value: Improper Restriction of Excessive Authentication Attempts in GitHub repository answerdev/answer prior to 1.0.6.
Severity: nan (CVSS v3 base score: 5.3)
Weakness: CWE-307 \u2014 Improper Restriction of Excessive Authentication Attempts
The product does not implement sufficient measures to prevent multiple failed authentication attempts within a short time frame, making it more susceptible to brute force attacks.
Repository: https://github.com/answerdev/answer
Files changed:
internal/repo/captcha/captcha.go
internal/service/action/captcha_service.go
Commit message: update VerifyCaptcha


Vulnerable code:

Fixed code:

func (cr *captchaRepo) DelCaptcha(ctx context.Context, key string) (err error) {
	err = cr.data.Cache.Del(ctx, key)
	if err != nil {
		log.Debug(err)
	}
	return nil
}
	DelCaptcha(ctx context.Context, key string) (err error)
		log.Error("VerifyCaptcha GetCaptcha Error", err.Error())
		return false, nil
	}
	err = cs.captchaRepo.DelCaptcha(ctx, key)
	if err != nil {
		log.Error("VerifyCaptcha DelCaptcha Error", err.Error())
CVE-2023-1540 (Go, published 2023-03-21T05:15Z)
Description: value: Observable Response Discrepancy in GitHub repository answerdev/answer prior to 1.0.6.
Severity: nan (CVSS v3 base score: 5.3)
Weakness: CWE-203 \u2014 Observable Discrepancy
The product behaves differently or sends different responses under different circumstances in a way that is observable to an unauthorized actor, which exposes security-relevant information about the state of the product, such as whether a particular operation was successful or not.
Repository: https://github.com/answerdev/answer
Files changed:
internal/controller/user_controller.go
internal/service/user_service.go
Commit message: fix(user): User reset password should not tell the user if the email exists.


Vulnerable code:
	_, err := uc.userService.RetrievePassWord(ctx, req)
func (us *UserService) RetrievePassWord(ctx context.Context, req *schema.UserRetrievePassWordRequest) (string, error) {
		return "", err
		return "", errors.BadRequest(reason.UserNotFound)
		return "", err
	return code, nil

Fixed code:
	err := uc.userService.RetrievePassWord(ctx, req)
func (us *UserService) RetrievePassWord(ctx context.Context, req *schema.UserRetrievePassWordRequest) error {
		return err
		return nil
		return err
	return nil
CVE-2023-1541 (Go, published 2023-03-21T05:15Z)
Description: value: Business Logic Errors in GitHub repository answerdev/answer prior to 1.0.6.
Severity: nan (CVSS v3 base score: 3.8)
Weakness: NVD-CWE-noinfo \u2014 Insufficient Information
There is insufficient information about the issue to classify it; details are unkown or unspecified.
Repository: https://github.com/answerdev/answer
Files changed:
i18n/en_US.yaml
internal/base/reason/reason.go
internal/service/user_admin/user_backyard.go
Commit message: fix(admin): add restriction about admin modify their password


Vulnerable code:

Fixed code:
      cannot_update_their_password:
        other: You cannot modify your password.
	AdminCannotUpdateTheirPassword   = "error.admin.cannot_update_their_password"
	// Users cannot modify their password
	if req.UserID == req.LoginUserID {
		return errors.BadRequest(reason.AdminCannotUpdateTheirPassword)
	}
CVE-2023-1542 (Go, published 2023-03-21T05:15Z)
Description: value: Business Logic Errors in GitHub repository answerdev/answer prior to 1.0.6.
Severity: nan (CVSS v3 base score: 5.4)
Weakness: NVD-CWE-noinfo \u2014 Insufficient Information
There is insufficient information about the issue to classify it; details are unkown or unspecified.
Repository: https://github.com/answerdev/answer
Files changed:
i18n/en_US.yaml
internal/base/reason/reason.go
internal/controller_admin/user_backyard_controller.go
internal/schema/backyard_user_schema.go
internal/service/user_admin/user_backyard.go
Commit message: fix(admin): add restriction about admin modify their status


Vulnerable code:
	// user id
	UserID string `validate:"required" json:"user_id"`
	// user status
	Status string `validate:"required,oneof=normal suspended deleted inactive" json:"status" enums:"normal,suspended,deleted,inactive"`

Fixed code:
      cannot_modify_self_status:
        other: You cannot modify your status.
	AdminCannotModifySelfStatus      = "error.admin.cannot_modify_self_status"
	req.LoginUserID = middleware.GetLoginUserIDFromContext(ctx)

	UserID      string `validate:"required" json:"user_id"`
	Status      string `validate:"required,oneof=normal suspended deleted inactive" json:"status" enums:"normal,suspended,deleted,inactive"`
	LoginUserID string `json:"-"`
	// Admin cannot modify their status
	if req.UserID == req.LoginUserID {
		return errors.BadRequest(reason.AdminCannotModifySelfStatus)
	}
CVE-2023-1543 (Go, published 2023-03-21T05:15Z)
Description: value: Insufficient Session Expiration in GitHub repository answerdev/answer prior to 1.0.6.
Severity: nan (CVSS v3 base score: 8.8)
Weakness: CWE-613 \u2014 Insufficient Session Expiration
According to WASC, "Insufficient Session Expiration is when a web site permits an attacker to reuse old session credentials or session IDs for authorization."
Repository: https://github.com/answerdev/answer
Files changed:
internal/controller/user_controller.go
Commit message: fix(user): Remove admin cache when user logout.


Vulnerable code:

Fixed code:
	_ = uc.authService.RemoveAdminUserCacheInfo(ctx, accessToken)
CVE-2023-1976 (Go, published 2023-04-11T11:15Z)
Description: value: Password Aging with Long Expiration in GitHub repository answerdev/answer prior to 1.0.6.
Severity: nan (CVSS v3 base score: 8.8)
Weakness: CWE-263 \u2014 Password Aging with Long Expiration
The product supports password aging, but the expiration period is too long.
Repository: https://github.com/answerdev/answer
Files changed:
internal/repo/captcha/captcha.go
internal/service/action/captcha_service.go
Commit message: update VerifyCaptcha


Vulnerable code:

Fixed code:

func (cr *captchaRepo) DelCaptcha(ctx context.Context, key string) (err error) {
	err = cr.data.Cache.Del(ctx, key)
	if err != nil {
		log.Debug(err)
	}
	return nil
}
	DelCaptcha(ctx context.Context, key string) (err error)
		log.Error("VerifyCaptcha GetCaptcha Error", err.Error())
		return false, nil
	}
	err = cs.captchaRepo.DelCaptcha(ctx, key)
	if err != nil {
		log.Error("VerifyCaptcha DelCaptcha Error", err.Error())
CVE-2023-2590 (Go, published 2023-05-09T06:15Z)
Description: value: Missing Authorization in GitHub repository answerdev/answer prior to 1.0.9.
Severity: nan (CVSS v3 base score: 3.5)
Weakness: CWE-862 \u2014 Missing Authorization
The product does not perform an authorization check when an actor attempts to access a resource or perform an action.
Repository: https://github.com/answerdev/answer
Files changed:
internal/migrations/init.go
internal/migrations/migrations.go
internal/migrations/v3.go
internal/migrations/v9.go
Commit message: fix(rank): update answer accept rank config


Vulnerable code:
		{ID: 44, Key: "rank.answer.accept", Value: `1`},
		{ID: 44, Key: "rank.answer.accept", Value: `1`},

Fixed code:
		{ID: 44, Key: "rank.answer.accept", Value: `-1`},
	NewMigration("update accept answer rank", updateAcceptAnswerRank, true),
		{ID: 44, Key: "rank.answer.accept", Value: `-1`},
package migrations

import (
	"fmt"

	"github.com/answerdev/answer/internal/entity"
	"github.com/segmentfault/pacman/log"
	"xorm.io/xorm"
)

func updateAcceptAnswerRank(x *xorm.Engine) error {
	c := &entity.Config{ID: 44, Key: "rank.answer.accept", Value: `-1`}
	if _, err := x.Update(c, &entity.Config{ID: 44, Key: "rank.answer.accept"}); err != nil {
		log.Errorf("update %+v config failed: %s", c, err)
		return fmt.Errorf("update config failed: %w", err)
	}
	return nil
}
CVE-2023-4124 (Go, published 2023-08-03T04:15Z)
Description: value: Missing Authorization in GitHub repository answerdev/answer prior to v1.1.1.
Severity: nan (CVSS v3 base score: 6.5)
Weakness: CWE-862 \u2014 Missing Authorization
The product does not perform an authorization check when an actor attempts to access a resource or perform an action.
Repository: https://github.com/answerdev/answer
Files changed:
internal/migrations/init.go
internal/migrations/init_data.go
internal/migrations/v3.go
internal/schema/siteinfo_schema.go
internal/service/siteinfo/siteinfo_service.go
Commit message: feat(init): set default privileges when init


Vulnerable code:
		{ID: 51, Key: "rank.tag.add", Value: `1`},
		{ID: 51, Key: "rank.tag.add", Value: `1`},
	DefaultPrivilegeOptions      []*PrivilegeOption
	var chooseOption *schema.PrivilegeOption
	for _, option := range schema.DefaultPrivilegeOptions {
		if option.Level == req.Level {
			chooseOption = option
			break
		}
	}

Fixed code:
	"github.com/answerdev/answer/internal/schema"
	"github.com/segmentfault/pacman/log"
	m.do("init default privileges config", m.initDefaultRankPrivileges)
	m.do("init site info privilege rank", m.initSiteInfoPrivilegeRank)
func (m *Mentor) initDefaultRankPrivileges() {
	chooseOption := schema.DefaultPrivilegeOptions.Choose(schema.PrivilegeLevel2)
	for _, privilege := range chooseOption.Privileges {
		_, err := m.engine.Context(m.ctx).Update(
			&entity.Config{Value: fmt.Sprintf("%d", privilege.Value)},
			&entity.Config{Key: privilege.Key},
		)
		if err != nil {
			log.Error(err)
		}
	}
}


func (m *Mentor) initSiteInfoPrivilegeRank() {
	privilegeRankData := map[string]interface{}{
		"level": schema.PrivilegeLevel2,
	}
	privilegeRankDataBytes, _ := json.Marshal(privilegeRankData)
	_, m.err = m.engine.Context(m.ctx).Insert(&entity.SiteInfo{
		Type:    "privileges",
		Content: string(privilegeRankDataBytes),
		Status:  1,
	})
}
		{ID: 51, Key: "rank.tag.add", Value: `1500`},
		{ID: 51, Key: "rank.tag.add", Value: `1500`},
type PrivilegeOptions []*PrivilegeOption

func (p PrivilegeOptions) Choose(level PrivilegeLevel) (option *PrivilegeOption) {
	for _, op := range p {
		if op.Level == level {
			return op
		}
	}
	return nil
}
	DefaultPrivilegeOptions      PrivilegeOptions
	chooseOption := schema.DefaultPrivilegeOptions.Choose(req.Level)
CVE-2023-4815 (Go, published 2023-09-07T07:15Z)
Description: value: Missing Authentication for Critical Function in GitHub repository answerdev/answer prior to v1.1.3.
Severity: nan (CVSS v3 base score: 8.8)
Weakness: CWE-306 \u2014 Missing Authentication for Critical Function
The product does not perform any authentication for functionality that requires a provable user identity or consumes a significant amount of resources.
Repository: https://github.com/answerdev/answer
Files changed:
internal/base/middleware/auth.go
internal/repo/activity/answer_repo.go
Commit message: fix(answer): fix incorrect notification's triggerUserID when cancel accepted answer


Vulnerable code:
		if err != nil {
	ar.data.DB.ShowSQL(true)
			msg.TriggerUserID = op.AnswerUserID
			msg.TriggerUserID = op.QuestionUserID
			msg.TriggerUserID = op.QuestionUserID
			msg.TriggerUserID = op.AnswerObjectID
			msg.TriggerUserID = op.QuestionObjectID

Fixed code:
		if err != nil || userInfo == nil {
			TriggerUserID:  act.TriggerUserID,
			TriggerUserID:  op.TriggerUserID,
			TriggerUserID:  act.TriggerUserID,